Sub topic 9
Your duties for network and resource configuration
This chapter assumes you know what a VPC, a security group, and an S3 bucket are, and that you can read a short AWS CLI command. AWS secures the physical network and the virtualization layer. You secure how your resources use them. Every network path and every setting on a resource you create is a customer-side choice.
What AWS handles and what you handle
AWS runs the data centers, the global backbone, and the hypervisor that keeps one customer's instances apart from another's. You decide what your VPC looks like and which traffic is allowed in. You also decide which resources are public and how each one is configured.
| Area | AWS | You |
|---|---|---|
| Physical network | Cabling, routers, backbone | Nothing |
| Isolation between customers | Hypervisor and network isolation | Nothing |
| VPC design | Provides the building blocks | Subnets, route tables, gateways |
| Traffic filtering | Provides security groups and network ACLs | Rules you write |
| Resource settings | Provides the options | Which options you turn on |
Network duties
Your network duties come down to a few decisions.
- Subnet placement. A subnet is public if its route table sends traffic to an internet gateway. Put only resources that must be reachable from the internet in public subnets. Keep databases and application servers in private subnets.
- Security groups. A security group is a stateful firewall attached to a resource. Allow only the ports and sources that the workload needs. Avoid
0.0.0.0/0on administrative ports such as 22 and 3389. - Network ACLs. A network ACL is a stateless filter at the subnet level. Use it as a second layer, not as a replacement for security groups.
- Private access to AWS services. VPC endpoints let your resources reach services such as S3 without sending traffic over the internet.
The following command finds security groups that allow SSH from anywhere.
aws ec2 describe-security-groups \
--filters Name=ip-permission.from-port,Values=22 \
Name=ip-permission.cidr,Values=0.0.0.0/0 \
--query "SecurityGroups[].[GroupId,GroupName]" \
--output tableAny group in the output is exposing SSH to the whole internet. AWS did not make that choice, and AWS will not undo it for you.
Resource configuration duties
A resource is only as safe as its settings. AWS gives you secure options, but you have to select them. S3 is a clear case. AWS operates the service, but whether a bucket is public depends on your configuration. This command turns on all four Block Public Access settings for one bucket.
aws s3api put-public-access-block \
--bucket amzn-s3-demo-bucket \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueThe same reasoning applies to other settings:
- Whether an RDS instance is publicly accessible.
- Whether logging is enabled, such as VPC Flow Logs and CloudTrail.
- Whether versioning and backups are turned on.
- Which AMI an EC2 instance starts from, and whether its operating system is patched.
How a request reaches a resource
The diagram shows the layers a request passes through. You configure every layer except the AWS infrastructure underneath.
Common errors
- Opening a security group to
0.0.0.0/0"temporarily" and never closing it. - Placing a database in a public subnet because it was easier to test.
- Assuming that a managed service is private by default. Check each service's access settings.
- Leaving the default VPC in use with its permissive defaults.
Check your work
Settings drift over time. A later chapter covers AWS Config in detail. This command lists the Config rules that currently report non-compliant resources.
aws configservice describe-compliance-by-config-rule \
--compliance-types NON_COMPLIANTExercise
A team puts an RDS database in a private subnet but sets it to publicly accessible and allows port 3306 from 0.0.0.0/0 in its security group. Who is responsible for fixing the exposure, and which two settings should change?
Show answer
The customer is responsible, because both settings are configuration choices on the customer side. Turn off public accessibility on the RDS instance, and restrict the security group rule to the application tier's security group or CIDR range instead of 0.0.0.0/0.
Exercise
Why is a network ACL not a replacement for a security group?
Show answer
A network ACL is stateless and applies at the subnet level, so you must write rules for both directions. A security group is stateful and attaches to individual resources. They work best as two layers.