Securing Workloads and Data
Design secure workloads and data protection on AWS: VPC layers, security groups vs network ACLs, edge protection with WAF and Shield, threat detection services, encryption with KMS, secrets management, and S3 data controls.
Defense in Layers
A secure architecture doesn’t depend on one control. An attacker who gets past one layer should hit another. A standard three-tier web app on AWS looks like this:
Security groups vs network ACLs
| Security group | Network ACL | |
|---|---|---|
| Attached to | An ENI (instance, load balancer, database) | A subnet |
| State | Stateful: return traffic is allowed automatically | Stateless: you must allow return traffic (ephemeral ports) explicitly |
| Rules | Allow only | Allow and deny |
| Evaluation | All rules evaluated together | Rules evaluated in number order; first match wins |
| Typical use | Primary control; reference other security groups by ID | Coarse subnet-level blocks, such as denying a known bad IP range |
If a question asks you to block a specific IP address, the answer is a network ACL (or AWS WAF for web traffic), because security groups can’t deny.
Private connectivity
- NAT gateway lets private instances reach the internet for updates without being reachable from it.
- VPC endpoints let private resources reach AWS services without the internet. Gateway endpoints cover S3 and DynamoDB at no charge. Interface endpoints (AWS PrivateLink) cover most other services.
- Systems Manager Session Manager gives shell access to instances with no open SSH port and no bastion host.
Edge Protection and Threat Detection
| Service | What it does | Exam cue |
|---|---|---|
| AWS WAF | Filters HTTP(S) requests: SQL injection, cross-site scripting, rate limits, geo blocking. Attaches to CloudFront, ALB, API Gateway, AppSync, Cognito | ”block SQL injection,” “rate-limit by IP” |
| AWS Shield Standard | Automatic protection against common network and transport layer DDoS attacks, at no extra cost | Included for everyone |
| AWS Shield Advanced | Paid: enhanced DDoS protection, 24/7 Shield Response Team, cost protection for scaling during an attack | ”large DDoS,” “response team” |
| Amazon GuardDuty | Threat detection from CloudTrail, VPC Flow Logs, DNS logs, and more | ”detect compromised instances,” “crypto mining” |
| Amazon Inspector | Vulnerability scanning for EC2, container images, and Lambda | ”find CVEs” |
| Amazon Macie | Finds sensitive data (PII) in S3 | ”discover PII in buckets” |
| AWS Security Hub | Aggregates findings and checks against security standards | ”single view of security posture” |
| AWS Config | Records resource configuration and evaluates compliance rules | ”detect unencrypted volumes,” “configuration history” |
| AWS CloudTrail | Logs API calls across the account or organization | ”who deleted this?”, audit |
Protecting Data
Encryption at rest with KMS
AWS Key Management Service (KMS) creates and controls encryption keys, and most AWS services integrate with it.
- AWS managed keys are created for you per service. Easy, but you can’t manage their key policy.
- Customer managed keys give you control over the key policy, rotation, and auditing, and you can share them across accounts.
- Envelope encryption: KMS encrypts a small data key, and the data key encrypts your data, so large objects never travel to KMS.
- AWS CloudHSM gives you dedicated, single-tenant hardware security modules when a regulation requires you to control the hardware.
Envelope encryption is how most AWS services use KMS behind the scenes:
Encryption for RDS and EBS is chosen at creation. To encrypt an existing unencrypted database, snapshot it, copy the snapshot with encryption on, and restore from the copy.
Encryption in transit
Use TLS everywhere. AWS Certificate Manager (ACM) issues and renews public certificates for free on CloudFront, ALB, and API Gateway. To force HTTPS for S3, add a bucket policy that denies requests where aws:SecureTransport is false.
Secrets
| AWS Secrets Manager | SSM Parameter Store | |
|---|---|---|
| Built-in rotation | Yes (native for RDS, Aurora, Redshift, DocumentDB; Lambda for others) | No |
| Cost | Per secret per month | Standard parameters are free |
| Best for | Database credentials and API keys that must rotate | Configuration values and simple secrets |
S3 data controls
- Block Public Access, on by default for new buckets, overrides any policy or ACL that would make data public.
- Default encryption with SSE-S3 is applied to all new objects; choose SSE-KMS when you need key-level access control and audit.
- Versioning protects against overwrites and deletes; MFA Delete adds a second factor for permanent deletes.
- S3 Object Lock provides write-once-read-many (WORM) retention for compliance.
- Presigned URLs give temporary access to a single object without making the bucket public.
Common mistake: the database security group allows port 3306 from 10.0.0.0/16, the whole VPC.
Now any instance in the VPC can try to connect, including a compromised one in another tier. Reference the app tier’s security group instead. When instances scale in and out, the rule still applies to exactly the right ones.
Key Takeaway
Put each tier in its own subnet, chain security groups by reference, use NACLs when you need to deny, and keep traffic private with NAT gateways and VPC endpoints. Protect the edge with WAF and Shield, detect threats with GuardDuty, and encrypt with KMS (at rest) and ACM/TLS (in transit). Rotate credentials with Secrets Manager.
In a sandbox VPC, create three security groups: alb-sg, app-sg, and db-sg.
alb-sg: allow inbound 443 from0.0.0.0/0.app-sg: allow inbound 8080 fromalb-sg(choose the security group as the source, not a CIDR).db-sg: allow inbound 5432 fromapp-sg.
Now answer: what changes when the app tier scales from 2 to 20 instances? (Nothing. The rules follow the group.) What would you add to block one abusive IP address at the subnet level? (A NACL deny rule.) And at the HTTP layer? (A WAF IP set rule.)
1. A company must block traffic from a specific malicious IP range to a subnet. What should they use?
Network ACLs support deny rules. Security groups only support allow rules.
2. Private EC2 instances need to read from S3 without traffic going over the internet, at the lowest cost. What should you add?
Gateway endpoints keep S3 traffic on the AWS network and have no hourly or data processing charge.
3. Which service automatically rotates RDS database credentials?
Secrets Manager has built-in rotation for RDS and other databases.
4. An existing RDS instance was created without encryption. How do you encrypt it?
RDS encryption is set at creation. Encrypting a copy of a snapshot and restoring it is the supported path.