Securing Workloads and Data
Module 2 · Design Secure Architectures

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:

InternetEdgeCloudFrontWAF + ShieldVPCPublic subnetALBSG: 443 from allPrivate appEC2SG: from ALB SGPrivate dataRDSSG: from app SGNACLNACLNACLKMS: encryption at rest (RDS, EBS, S3)ACM: TLS certsEach tier only accepts traffic from the tier in front of it, by referencing that tier’s security group.

Security groups vs network ACLs

Security groupNetwork ACL
Attached toAn ENI (instance, load balancer, database)A subnet
StateStateful: return traffic is allowed automaticallyStateless: you must allow return traffic (ephemeral ports) explicitly
RulesAllow onlyAllow and deny
EvaluationAll rules evaluated togetherRules evaluated in number order; first match wins
Typical usePrimary control; reference other security groups by IDCoarse 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

ServiceWhat it doesExam cue
AWS WAFFilters 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 StandardAutomatic protection against common network and transport layer DDoS attacks, at no extra costIncluded for everyone
AWS Shield AdvancedPaid: enhanced DDoS protection, 24/7 Shield Response Team, cost protection for scaling during an attack”large DDoS,” “response team”
Amazon GuardDutyThreat detection from CloudTrail, VPC Flow Logs, DNS logs, and more”detect compromised instances,” “crypto mining”
Amazon InspectorVulnerability scanning for EC2, container images, and Lambda”find CVEs”
Amazon MacieFinds sensitive data (PII) in S3”discover PII in buckets”
AWS Security HubAggregates findings and checks against security standards”single view of security posture”
AWS ConfigRecords resource configuration and evaluates compliance rules”detect unencrypted volumes,” “configuration history”
AWS CloudTrailLogs 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:

AWS KMSKMS keynever leaves KMSunencryptedService or app3. Encrypt the datawith the plaintextdata key, thendiscard that keyStored togetherEncrypted dataEncrypted data key1. GenerateDataKey2. Plaintext key+ encrypted copy4. StoreTo decrypt: send the encrypted data key to KMS, get the plaintext key back, and decrypt locally.Large data never travels to KMS. Only the small data key does.

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 ManagerSSM Parameter Store
Built-in rotationYes (native for RDS, Aurora, Redshift, DocumentDB; Lambda for others)No
CostPer secret per monthStandard parameters are free
Best forDatabase credentials and API keys that must rotateConfiguration 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 Pitfall: Opening the Database to the VPC CIDR

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.

🧪 Try It: Chain Security Groups

In a sandbox VPC, create three security groups: alb-sg, app-sg, and db-sg.

  1. alb-sg: allow inbound 443 from 0.0.0.0/0.
  2. app-sg: allow inbound 8080 from alb-sg (choose the security group as the source, not a CIDR).
  3. db-sg: allow inbound 5432 from app-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.)

🧠 Knowledge Check

1. A company must block traffic from a specific malicious IP range to a subnet. What should they use?

2. Private EC2 instances need to read from S3 without traffic going over the internet, at the lowest cost. What should you add?

3. Which service automatically rotates RDS database credentials?

4. An existing RDS instance was created without encryption. How do you encrypt it?