AWS 055: Public and private subnets
The problem
A team uses Public and private subnets as a label or Console setting without proving the identity, scope, behavior, failure boundary, cost, or operational result. The configuration appears complete but the real requirement remains untested.
Final outcome
The learner will inspect, explain, test, and document Public and private subnets. The submission must connect the Console and CLI view to the same AWS control, state what the evidence proves, diagnose one likely failure, and make a requirement-based architecture decision.
Learning outcomes
You will be able to:
- explain a subnet is an az-scoped address range;
- explain public and private describe routing;
- explain public ipv4 also matters;
- explain aws reserves five addresses;
- explain automatic public address assignment is a subnet setting;
- distinguish successful configuration from successful workload behavior;
- preserve redacted evidence and complete the stated cleanup or retention decision.
Mental model
requirement
-> identity and permission
-> account, Region, and resource scope
-> configuration or request
-> observable state
-> workload result
-> failure evidence
-> cleanup or controlled retention
Never begin with a create button or a copied command. Start with the result that must be proven and the boundary that must remain protected.
Core facts
| Concept | What it means in practice |
|---|---|
| A subnet is an AZ-scoped address range | A subnet belongs to one Availability Zone and one VPC. Its IPv4 and IPv6 CIDRs must come from associated VPC ranges and cannot overlap another subnet in that VPC. |
| Public and private describe routing | A public subnet has a route to an internet gateway. A private subnet lacks a direct internet-gateway route. The label does not prove that every resource is reachable or isolated. |
| Public IPv4 also matters | For direct IPv4 internet communication, an instance normally needs a public IPv4 or Elastic IP, an internet-gateway route, permissive security controls, and a listening application. |
| AWS reserves five addresses | For each IPv4 subnet, AWS reserves the first four addresses and the last address. A /24 therefore has 251 usable IPv4 addresses, while a /28 has 11. |
| Automatic public address assignment is a subnet setting | The subnet attribute controls whether newly launched network interfaces request public IPv4 addresses by default. Launch settings can override supported behavior. |
| Private subnets need explicit service paths | Use NAT for outbound IPv4 internet, gateway or interface endpoints for supported services, and VPN, Direct Connect, peering, or transit routing for private networks. |
How to reason about it
Use one subnet per tier per Availability Zone rather than calling an entire VPC public or private. Public load balancers can occupy public subnets while application and database resources use private subnets. Routes define the path; security groups, network ACLs, identity policies, and application settings define whether access succeeds.
Use the following decision table as a starting point, then change the answer when the scenario changes.
| Requirement | Preferred direction | Why |
|---|---|---|
| Internet-facing load balancer | Public subnets in at least two AZs | It needs internet-gateway routing and zonal addresses for resilient public entry. |
| Application servers need updates but no inbound internet | Private subnets with endpoints or NAT | They initiate required traffic without direct public addressing. |
| Database accepts only application traffic | Private database subnets and restrictive security groups | No direct internet route is needed for the data tier. |
| Small subnet is filling with endpoints and load balancers | Create larger or additional planned subnets | AWS-reserved and service-consumed addresses reduce usable capacity. |
Prerequisites, permissions, Region, and cost
Run this lesson as the approved non-root course identity. Begin with aws sts get-caller-identity, confirm the private account record, and set the fixed project Region before any regional query. IAM resources are global within an account, while STS endpoints and the services reached by an identity can be regional.
Use only the read or change actions required for this lesson. An AccessDenied result is evidence to analyse, not permission to switch to root or attach AdministratorAccess. Record the action, resource, principal type, request context, and smallest justified correction.
The listed cost tier is T0 - no resource creation. Free Tier eligibility and credits are account-specific. Before a mutating lab, identify every resource that can charge, estimate its duration, start a timer, and write the reverse cleanup order. A budget reports cost after billing data arrives and is not a real-time stop control.
AWS Management Console method
- Open VPC Subnets and select one subnet.
- Inspect its Availability Zone, CIDR, available addresses, public-IPv4 assignment attribute, route table, and network ACL.
- Open the associated route table and classify the subnet from its actual gateway or NAT path, not its name tag.
For every step record the service page, selected account and Region, exact object, visible state, and why that state matters. A Console label or green status is not enough unless it is tied to the final workload outcome.
AWS CLI or API evidence
Join subnet attributes with their associated route tables before assigning a public or private label.
aws ec2 describe-subnets --query 'Subnets[].{Subnet:SubnetId,AZ:AvailabilityZone,CIDR:CidrBlock,AutoPublic:MapPublicIpOnLaunch,Free:AvailableIpAddressCount}' --output table
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0123456789abcdef0
AutoPublic is not the route. Confirm a 0.0.0.0/0 route to an internet gateway and the resource public address separately.
Before running the command, replace every placeholder, explain each option, and decide whether the operation is read-only or mutating. Capture the exit code immediately. Redact account IDs, ARNs, public addresses, request identifiers, and personal data before sharing.
The CLI and Console are clients of AWS APIs. Matching state across them increases confidence, but neither substitutes for data-plane or application verification.
Practical work
Create p04-subnet-plan.md. Place the four approved /24 blocks across two Availability Zones using the zone names and zone IDs visible to this account. For every subnet state its tier, route intention, public-IPv4 assignment intention, NACL association, available-address calculation, and failure-domain purpose. Explain that a name containing public does not make a subnet public.
The evidence package must include:
- non-root principal type, account verified privately, and Region;
- exact intended and observed state;
- one Console observation and the matching CLI or API result;
- one successful result and one denied, failed, or counterexample result;
- what each result does not prove;
- cost state and elapsed lab time;
- cleanup evidence or a named retained-state owner and next lesson.
Verification standard
Use three levels of proof:
- Control plane: the object or policy exists with the intended configuration.
- Data plane or behavior: the request, packet, session, storage path, or application does what the requirement states.
- Operations: monitoring, failure diagnosis, cost, ownership, and cleanup are known.
A control-plane response can precede final readiness. Use waiters or state polling where supported, then test the actual behavior. If a request times out, do not assume it failed. Inspect state and use documented idempotency before retrying a mutation.
Troubleshooting method
| Symptom | Evidence first | Smallest safe response |
|---|---|---|
| command cannot authenticate | credential source, expiry, caller preflight | restore approved temporary login |
| access is denied | action, resource, principal, all policy layers | correct only the missing or conflicting control |
| object appears missing | account, Region, filters, pagination, permission | align scope before creating anything |
| configured state exists but behavior fails | route, identity, dependency, logs, service state | test the next boundary in the path |
| cleanup is blocked | dependency inventory and owning service | remove dependants in reviewed reverse order |
Keep the original symptom and timestamp. State one hypothesis, make one reversible change, repeat the original test, and record rollback. Never open a management port to the world, expose credentials, disable TLS verification, format an unknown disk, or add broad permissions as a generic fix.
Architecture and certification decisions
Professional-level questions provide competing valid features. Identify the requirement that decides between them: human or workload identity, same-account or cross-account access, regional or zonal scope, stateful or stateless filtering, durable or ephemeral data, latency, RTO/RPO, cost, or operational ownership.
Explain why the selected option fits and why each plausible alternative fails one stated requirement. Do not rely on feature memorization or reproduce protected certification questions.
Knowledge check
- Does naming a subnet private make it private?
Expected direction: No. Inspect its routes, addressing, gateways, endpoints, and security controls.
- How many usable IPv4 addresses are in an AWS /28 subnet?
Expected direction: Eleven because sixteen total addresses minus five AWS-reserved addresses remain.
- Can one subnet span two Availability Zones?
Expected direction: No. Create a subnet for each required AZ.
- Does a public subnet route automatically give an instance a public IPv4 address?
Expected direction: No. Public addressing is a separate requirement.
Cost, cleanup, and retained state
Retain only the state explicitly required by the next P04 lesson and record it in the private resource ledger.
Cleanup evidence includes the final state query, not only a successful delete response. Search related resources, other Regions used by the lab, retained storage, public IPv4 addresses, logging destinations, and service-managed dependencies. Schedule a later billing review because cost data can lag.
Completion gate
Pass when the practical artifact explains the real problem, matches Console and CLI evidence, answers every knowledge check, diagnoses one failure without broadening access, records cost, and proves cleanup or approved retention. The learner must defend one decision orally and name the requirement that would change it.