Skip to content
Certification Guide

Task 1.2 · 24 min read

Secure Workloads and Applications

Services in this lesson

  • Amazon VPCin scope
  • AWS PrivateLinkin scope
  • AWS Site-to-Site VPNin scope
  • AWS Direct Connectin scope
  • AWS WAFin scope
  • AWS Shieldin scope
  • AWS Secrets Managerin scope
  • AWS Systems Managerin scope
  • Amazon Cognitoin scope
  • Amazon GuardDutyin scope
  • Amazon Maciein scope
  • Amazon Inspectorin scope

What the exam tests

  • Whether you can segment a VPC (virtual private cloud, your own private network in AWS) into subnets, slices of its address range. Which tier (one layer, such as web, app or database) goes in a public subnet, which in a private one, and which route makes the difference?
  • Whether you pick the right traffic filter. That's a security group that names another security group, a network ACL (access control list) for a subnet-wide deny, or AWS WAF (a web application firewall) for web attacks.
  • Whether private workloads reach the internet or AWS services without being reachable: a NAT gateway for outbound-only internet access, and VPC endpoints so AWS traffic needs no internet path.
  • Whether you protect outside connections: Site-to-Site VPN versus Direct Connect, and when Direct Connect needs encryption on top. Plus AWS Shield for DDoS (distributed denial of service) floods and AWS WAF for web exploits.
  • Whether you match application security services to the job: Secrets Manager or Parameter Store for credentials, Amazon Cognito for app users, and GuardDuty, Macie and Inspector for detection.

The core concept

A request reaches your workload through several layers, and each layer answers one question. The exam rewards the answer that puts each check at the right layer.

An analogy: a hotel

Picture a hotel. Its protections map to five of the layers:

  • A doorman at the street entrance opens every bag and turns away anyone carrying something dangerous. That's AWS WAF at the edge.
  • The lobby has a door to the street, and the staff floors don't. That's the difference between a public subnet and a private subnet.
  • A floor guard checks a printed list for everyone stepping onto the floor and again for everyone leaving. The guard remembers nobody. That's a network ACL.
  • Each room door opens only for badges on its list, and lets back out anyone it let in. Its list can say "anyone with a kitchen badge" instead of names. That's a security group, which sits on each network interface (the virtual network card on an instance).
  • Staff can send a courier out the service door and get the reply back, but no stranger can walk in that way. That's a NAT gateway.

Where the analogy breaks: guards and doors are places, but network ACLs and security groups are rule lists attached to a subnet and to a network interface.

Walk one request through it

The diagram shows every layer. The walkthrough follows one customer's request through it, then the traffic the app starts on its own.

Enlarge
Each layer answers one question: what may enter the VPC, which subnet it can reach, and which instance accepts it.

Aisha buys a book from Tidewater Books, a web shop in one VPC. Its app runs on Amazon EC2 instances (virtual servers) in private subnets, behind an internet-facing Application Load Balancer (ALB).

  1. Aisha's request reaches the edge. An AWS WAF web ACL (a set of rules for web requests) on the ALB reads the HTTP request itself. It would block an SQL injection attempt (database commands hidden in user input), requests from a country you block, or one IP sending too many requests.
  2. AWS Shield Standard is already there. It protects every AWS customer against common layer 3 and 4 (network and transport) DDoS floods at no extra charge.
  3. The internet gateway lets the request into the public subnet. An internet gateway is the VPC's door to the internet. The subnet's route table (its list of where traffic may go) sends 0.0.0.0/0, every IPv4 address, to that gateway, which makes the subnet public. The ALB's security group, alb-sg, allows HTTPS on port 443 from anywhere.
  4. The ALB forwards the request to an app instance in a private subnet. That subnet has no route to the internet gateway. Its security group, app-sg, accepts port 8080 only from members of alb-sg.
  5. The app reads the database password. It asks AWS Secrets Manager through an interface endpoint, a private doorway into an AWS service, so the call stays on the AWS network instead of crossing the internet.
  6. The app queries the database in a private data subnet. The database's db-sg accepts port 5432 only from app-sg. The data subnet has no route out at all.
  7. The app saves Aisha's receipt to Amazon S3 (object storage). It travels through a gateway endpoint, a route-table target for S3 and Amazon DynamoDB (a key-value database). The bucket policy refuses any request that didn't come through that endpoint.
  8. The app downloads a security patch. The request goes out through the NAT gateway in the public subnet, and the reply comes back the same way. A scanner on the internet still can't start a connection to the app instance.
  9. Omar, an engineer at head office, opens an internal admin page. His traffic arrives over Site-to-Site VPN or AWS Direct Connect at a virtual private gateway, the VPC's side of the VPN connection. A transit gateway, a hub that links many VPCs and on-premises networks, can take its place.
    • The app subnet's route table needs a route back to the office's address range.
    • Omar reaches the app tier only because app-sg also lists the head-office IP range (a CIDR block) as a second source. Without that rule, the app tier refuses him like any other outsider.

Remove the internet gateway route from step 3 and the "public" subnet is private, whatever its name.

The rules the exam tests

  • Public means a route. A subnet is public only when its route table sends 0.0.0.0/0 to an internet gateway. Its instances also need public IPv4 addresses to use that route.
  • A NAT gateway is one-way. It lets connections out and their replies back in. It never accepts a connection started outside the VPC.
  • Security groups are stateful and allow-only. They guard each network interface, let replies back automatically, and can name another security group as the source.
  • Network ACLs are stateless and can deny. They guard the subnet edge and treat replies as new traffic. Their numbered rules are checked lowest number first, and checking stops at the first match.
  • Of these filters, only AWS WAF reads the HTTP request. Security groups and network ACLs see only addresses and ports.
  • Endpoints keep AWS traffic off the internet. Gateway endpoints serve S3 and DynamoDB. Interface endpoints serve most other services.
  • Detection isn't blocking. GuardDuty, Macie and Inspector detect and report. They don't block anything.
Deep diveNetwork ACL rule order and defaults
  • Rules run in ascending number, and the first match wins. A deny numbered 200 never runs if an allow numbered 100 already matched. Number the deny lower, for example 90.
  • The default network ACL allows all traffic in and out.
  • A new custom network ACL denies everything until you add rules.
  • A network ACL filters by CIDR block only. A CIDR block is an IP address range such as 10.0.0.0/16. It can't name a security group.
Deep diveNAT gateways and Availability Zones

A NAT gateway is created in one Availability Zone (AZ), and it's redundant only inside that zone. If that zone fails, private instances in other zones that route through it lose outbound internet access.

Create a NAT gateway in each AZ, and point each private route table at the one in its own zone. A regional NAT gateway is the other option. It spans the Region's Availability Zones instead of living in one, and it doesn't need a public subnet.

That's the network path. Inside the workload, four more choices decide how the app holds secrets, signs in users, lets administrators in and spots trouble.

Inside the workload

  • Secrets live in AWS Secrets Manager, not in a config file. It can rotate database passwords automatically. Plain settings go in Systems Manager Parameter Store.
  • App users sign in through Amazon Cognito. A user pool is the user directory and issues tokens. An identity pool swaps those tokens for temporary AWS credentials.
  • Administrators connect through Session Manager, part of AWS Systems Manager, instead of an open SSH (Secure Shell) port.
  • Detection services watch from the side. GuardDuty, Macie and Inspector report problems for someone else to act on.

Who may call AWS APIs is a separate question: IAM policies, roles and IAM Identity Center belong to 1.1 Secure access. Encryption keys and certificates belong to 1.3 Data security.

Decision guide

Decision guide
If the question says…Reach for…Because…
"only the web tier may reach the database", "instances scale in and out"A database security group whose inbound rule names the web tier's security group as the sourceThe rule follows group membership, not IP addresses, so new instances need no edits
"block a specific IP range" from reaching a subnetA network ACL DENY rule numbered below the allow rulesSecurity groups can't deny. Network ACLs can, and the lowest-numbered match wins
"instances in private subnets must download updates", "no inbound connections"NAT gateway per AZ (public subnet) or a regional one; private routes send 0.0.0.0/0 to itA NAT gateway only carries connections started inside the VPC
"access Amazon S3 or DynamoDB without the internet", "traffic must stay private"A gateway VPC endpoint on the private route tables, plus a bucket policy that requires that aws:SourceVpceThe route keeps traffic off the internet; the policy refuses anything that skipped it
"private access to Secrets Manager, AWS KMS, Amazon SQS…" from subnets with no internet pathAn interface VPC endpoint (AWS PrivateLink) with private DNS and a security groupIt puts private-IP network interfaces in your subnets, and existing SDK calls resolve to them
"SQL injection", "cross-site scripting", "block countries", "too many requests from one IP"AWS WAF web ACL on CloudFront, ALB or API Gateway: managed rule groups, geo match, rate-based ruleOf these filters, only AWS WAF reads the HTTP request; network ACLs and security groups see addresses and ports
"large DDoS attacks", "24/7 access to DDoS experts", "credits for scaling charges"AWS Shield Advanced on CloudFront, Route 53, Global Accelerator, an ALB or Elastic IPsAdds the Shield Response Team, automatic layer 7 mitigation through WAF, and cost protection
"database password rotated automatically", "no credentials in code"AWS Secrets Manager, with managed rotation for supported services such as RDS and RedshiftRotation is built in; Parameter Store has none
"configuration values", "AMI IDs", "feature settings", "lowest cost"Systems Manager Parameter Store, with SecureString for values that must be encryptedStandard parameters cost nothing extra; advanced ones allow larger values and policies
"users of our mobile or web app sign up and sign in", "Google or Apple login"An Amazon Cognito user poolIt's the user directory, and it issues tokens your app or API Gateway checks
"app users upload directly to their own S3 prefix"An Amazon Cognito identity pool behind the user poolIt swaps the user's token for temporary, limited AWS credentials
"administrators need shell access without SSH ports, bastions or keys"Systems Manager Session ManagerAccess is granted with IAM and logged, with no inbound ports open
"encrypted connection to the data center quickly", "over the internet"AWS Site-to-Site VPNTwo IPsec tunnels per connection over the internet, with no circuit to order
"consistent private connection" and "encrypted in transit"AWS Direct Connect with MACsec, or a Site-to-Site VPN over Direct ConnectDirect Connect doesn't encrypt traffic by default
"detect compromised instances, crypto mining, unusual API calls"Amazon GuardDutyIt reads CloudTrail management events, VPC flow logs and DNS logs as soon as it's on
"find PII or credit card numbers in S3 buckets"Amazon MacieIt finds sensitive data in S3 and flags buckets that become public
"scan EC2 instances, ECR images or Lambda functions for known vulnerabilities (CVEs)"Amazon InspectorIt finds workloads itself and rescans when packages change or new CVEs appear

Abbreviations and names in the table:

  • CloudFront is Amazon CloudFront, the AWS content delivery network. API Gateway is Amazon API Gateway, which fronts APIs.
  • KMS is AWS Key Management Service, SQS is Amazon Simple Queue Service, and RDS is Amazon Relational Database Service.
  • SDK is a software development kit, and DNS is the Domain Name System.
  • IPsec and MACsec are encryption protocols for network traffic.
  • PII is personally identifiable information. A CVE (Common Vulnerabilities and Exposures entry) is a publicly listed software flaw.
  • ECR is Amazon Elastic Container Registry, and an AMI is an Amazon Machine Image.

Correct pattern

REFERENCE PATTERN: a three-tier web application in one VPC (10.0.0.0/16) across two Availability Zones. Only the load balancer is reachable from the internet. The app tier reads its database password from Secrets Manager, and the reports bucket accepts requests only through the VPC's gateway endpoint.

1. Subnets and route tables. Each role gets its own route table, because the route table makes a subnet public or private.

Subnet (per AZ)HoldsRoute table entries
PublicALB nodes, NAT gateway10.0.0.0/16 → local, 0.0.0.0/0 → igw-…
Private appEC2 Auto Scaling group10.0.0.0/16 → local, 0.0.0.0/0 → nat-… (same-AZ NAT gateway), S3 prefix list → vpce-…
Private dataAmazon RDS (Multi-AZ)10.0.0.0/16 → local only

2. Security groups that reference each other. No tier below the load balancer has an IP-based inbound rule.

Security groupInbound ruleSource
alb-sgTCP 4430.0.0.0/0
app-sgTCP 8080alb-sg
db-sgTCP 5432app-sg
vpce-sgTCP 443 (Secrets Manager endpoint)app-sg

3. Bucket policy that refuses any request that didn't arrive through the gateway endpoint.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "OnlyThroughOurEndpoint",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::example-reports-bucket",
        "arn:aws:s3:::example-reports-bucket/*"
      ],
      "Condition": {
        "StringNotEquals": { "aws:SourceVpce": "vpce-0example1234567890" }
      }
    }
  ]
}

Read it from the outside in:

  1. The internet reaches only alb-sg, and only on port 443.
  2. Each tier accepts only the tier in front of it. The app tier trusts alb-sg and the database trusts app-sg, so the chain holds while Auto Scaling replaces instances.
  3. The data subnets have no route out at all.
  4. The bucket policy turns the endpoint into a control. A leaked credential used from a laptop is refused, because its request carries no matching aws:SourceVpce.
  5. The default network ACL stays in place and allows all traffic. That's fine here, because the security groups carry the rules. Add a custom network ACL only when you need a subnet-wide deny.
Deep diveSide effect: the deny can lock out the S3 console

The same deny can also block S3 console access to that bucket. Console requests don't come through your endpoint, so they carry no matching aws:SourceVpce.

Deep diveReturn traffic through a custom network ACL

A custom network ACL needs outbound rules for the replies, because it's stateless. Replies go to an ephemeral port, a short-lived port the client picks for one connection.

The range depends on the client's operating system. Many Linux kernels use 32768–61000, while Windows Server 2008 and later use 49152–65535.

AWS suggests opening 1024–65535 to cover the clients you can't predict.

Traps

TRAPExam traps
The trapWhy it failsCorrect pattern
A custom network ACL that allows inbound HTTPS and nothing outboundStateless, so replies on ephemeral ports hit the default deny. Tempting because a security group needs only inboundAdd an outbound rule for the clients' ephemeral ports (1024–65535 covers most) next to each allow
Trying to block an attacker's IP with a security groupSecurity groups only allow. Removing one allow doesn't help while a broader one such as 0.0.0.0/0 still matchesA network ACL deny numbered before the allows, or an AWS WAF IP set for web traffic
A network ACL deny rule numbered 200 behind an allow numbered 100The first match wins, so the deny never runs. It looks right because both rules are presentNumber denies below the allows (for example 90 before 100)
Putting the database in a public subnet "because the security group protects it"One bad rule or public IP exposes it. Tempting because testing from a laptop is easyA private data subnet with no internet route; reach it through the app tier, Session Manager or a VPN
Expecting AWS Direct Connect to be encrypted because it's a private circuitDirect Connect doesn't encrypt by default. Private means off the internet, not encryptedMACsec on a supported dedicated connection, or a Site-to-Site VPN over Direct Connect
Associating AWS WAF with a Network Load BalancerWAF doesn't protect NLBs. Tempting because an NLB is "the load balancer"Put CloudFront or an ALB in front and attach the web ACL there
Storing a database password in Parameter Store and expecting it to rotateParameter Store has no rotation. Tempting because SecureString is encrypted and the standard tier is freeSecrets Manager with managed rotation, or a rotation Lambda function for other secrets
Buying Shield Advanced to stop SQL injection, or GuardDuty to block an attackShield is for DDoS, and the detection services only report. Neither blocks a malicious HTTP payloadAWS WAF blocks web exploits; send detection findings to EventBridge or Security Hub CSPM to respond
Deep diveWhich resources AWS WAF can protect

AWS WAF protects CloudFront, ALBs, API Gateway REST APIs, AWS AppSync, Cognito user pools and a few other resources. A Network Load Balancer (NLB) isn't one of them.

Compare

Compare
CharacteristicSecurity groupNetwork ACL
Applies toNetwork interfaces (instances, endpoints, load balancers)Every resource in the associated subnets
Rule typesAllow onlyAllow and deny
Rule evaluationAll rules together, as one setIn ascending rule number; first match wins
Return trafficAllowed automatically (stateful)Needs its own rule (stateless)
Source optionsCIDR, prefix list, or another security groupCIDR only
New one starts withNo inbound, all outbound allowedCustom: deny everything; default ACL: allow everything
Default quotas60 inbound and 60 outbound rules; 5 groups per network interface20 inbound and 20 outbound rules; one ACL per subnet
Typical exam cue"only the app tier may connect", "least privilege between tiers""block this IP range", "second layer of defense for the subnet"

Credentials and configuration:

NeedAWS Secrets ManagerSystems Manager Parameter Store
Built forDatabase credentials, API keys, OAuth tokensConfiguration data, AMI IDs, endpoint URLs
RotationAutomatic: managed for services such as RDS and Redshift, or via LambdaNone
EncryptionAlways, with AWS KMSOptional, SecureString with AWS KMS
Size and scaleUp to 64 KB per secret10,000 standard and 100,000 advanced parameters per account and Region; standard values up to 4 KB, advanced up to 8 KB
Cost modelPer secret per month and per API callStandard tier at no extra charge; advanced tier is billed
OtherReplication to other Regions, cross-account accessParameter policies (advanced tier)

Detection services, which find problems but don't block traffic:

ServiceLooks atAnswers
Amazon GuardDutyCloudTrail events, VPC flow logs, DNS logs, plus optional plans"Is something in my account behaving like an attacker?"
Amazon InspectorEC2 instances, ECR container images, Lambda functions"Which workloads run software with known vulnerabilities?"
Amazon MacieObjects and bucket settings in Amazon S3"Where is our sensitive data, and is it exposed?"
Amazon DetectiveLog data linked into a behavior graph, with GuardDuty findings"What led up to this finding, and how far did it spread?"
AWS Security Hub CSPMFindings from the services above plus best-practice checks"What is our overall security posture, in one place?"

Connections from outside AWS:

ConnectionWhat it isEncryptionTypical exam cue
AWS Site-to-Site VPNTwo IPsec tunnels per connection over the internetYes, IPsec; 1.25 Gbps per standard tunnel"encrypted", "quickly", "over the internet"
AWS Direct ConnectA private circuit with consistent performanceNot by default; add MACsec or a VPN"consistent", "private connection"
AWS Client VPNAccess for individual remote usersTLS, with an OpenVPN-based client"remote employees", "laptops"

Abbreviations: TLS is Transport Layer Security, the encryption behind HTTPS. OAuth is a standard for app access tokens, and CSPM stands for cloud security posture management.

Throughput and routing choices between these belong to 3.4 Network performance.

Worked exam scenario

Exam scenario

A company runs an order-tracking website on Amazon EC2 instances in private subnets behind an internet-facing Application Load Balancer. Logs show attempts to inject SQL statements through query strings, and a few hundred IP addresses that change every day send thousands of requests per minute each, slowing the site. The company wants to block both kinds of traffic without changing application code, and with the LEAST operational overhead. What should a solutions architect do?

  1. A.Add deny rules for the offending IP addresses to the network ACL of the public subnets, and update the rules every day from the logs.
  2. B.Subscribe to AWS Shield Advanced and add the Application Load Balancer as a protected resource.
  3. C.Associate an AWS WAF web ACL with the Application Load Balancer that uses the AWS managed SQL database rule group and a rate-based rule.
  4. D.Enable Amazon GuardDuty and send its findings to Amazon EventBridge to notify the operations team.
Show the walkthrough
  1. Underline the requirements. There are two threats. "Inject SQL statements" is an application-layer payload, and "thousands of requests per minute" from "IP addresses that change every day" is a request flood. "Without changing application code" and "LEAST operational overhead" rule out daily manual upkeep.
  2. Eliminate A. A network ACL sees only IP addresses and ports, so it can't spot SQL in a query string. Daily rule updates are the overhead the stem forbids, and the default quota of 20 inbound rules runs out fast.
  3. Eliminate B. Shield Advanced is built for DDoS protection. It doesn't inspect query strings or request bodies for SQL injection. So the injection half still needs WAF, and a DDoS subscription isn't the right tool for it.
  4. Eliminate D. GuardDuty detects and notifies. The stem asks to block, and someone would still have to act on every alert.
  5. Land on C. AWS WAF attaches to the ALB. The managed SQL database rule group blocks SQL injection patterns in the request, such as in query strings. A rate-based rule blocks any IP whose requests exceed the limit within its evaluation window. AWS updates the managed rules, and the rate-based rule catches new IPs with no edits.

Answer: C

Check your understanding

Question 1: A subnet's instances have public IPv4 addresses, but the subnet's route table has no route to an internet gateway. Which change makes the subnet public?
Question 2: A network ACL has inbound rule 100 ALLOW TCP 22 from 0.0.0.0/0 and rule 110 DENY TCP 22 from 198.51.100.0/24. A connection arrives from 198.51.100.7 on port 22. What happens?
Question 3: A mobile app must let users sign in with Apple or Google and then upload photos straight to Amazon S3. Which TWO Amazon Cognito components does it need? (Choose TWO.)
Question 4: A NAT gateway runs in a public subnet in Availability Zone A. Private instances in Availability Zone B send their internet traffic through it. Availability Zone A has an outage. What happens to the instances in Availability Zone B?

Build it

Do the security groups and network ACLs lab. You build a one-subnet VPC with a small web server. Then you watch a stateless network ACL drop the replies, and a numbered deny rule block your own IP while the security group still allows it.

Neighboring topics live in other lessons:

Key takeaways

  • A subnet is public only because its route table points 0.0.0.0/0 at an internet gateway. Keep app and data tiers private, with outbound-only internet through a NAT gateway.
  • Security groups are stateful, allow-only and can reference each other. Network ACLs are stateless, numbered, can deny, and need rules for return traffic.
  • Gateway endpoints (S3, DynamoDB) and interface endpoints (most other services) keep AWS traffic off the internet. A bucket policy with aws:SourceVpce makes the endpoint the only way in.
  • AWS WAF stops web attacks on CloudFront, ALBs and API Gateway. Shield Standard is automatic, and Shield Advanced adds the response team and cost protection. Direct Connect needs MACsec or a VPN for encryption.
  • Credentials go in Secrets Manager (with rotation), configuration in Parameter Store, and app users in Cognito. GuardDuty, Inspector and Macie detect but don't block.
  • Keep each tier as private as possible, allow with security groups, deny with network ACLs, reach AWS through endpoints, and stop exploits with AWS WAF and floods with AWS Shield.

Hands-on lab: Stateless Network ACLs and Stateful Security Groups

Sources

Last reviewed