By the end you'll know
- How a name becomes an address, and the difference between registering a domain and hosting its DNS
- The record types you'll meet, and why AWS has alias records
- What CloudFront does, how to read its cache headers, and how to keep people from going around it
- How certificates are issued and validated, and why CloudFront's must be in us-east-1
- What WAF rules, managed rule groups and rate limits do, and what Shield adds
- Route 53's routing policies, for the exam
Before you start
- You need: the
juniper-ryeprofile from Lesson 4, signed in. No server, no VPC: everything here runs at AWS's edge. - The script:
edge-lab.shfrom the practice folder'slesson-14. Everything it creates is namedjr-lesson14-*, and itsdeletestep removes it. - How the script talks to AWS: only through the AWS CLI. The few lines of Python in it just turn the CLI's JSON into readable tables and never connect to AWS; boto3, AWS's Python library, comes in Lesson 20.
- To see every call the script makes, put
SHOW=1in front of any step, such asSHOW=1 ./edge-lab.sh cdn. The lesson's "By hand" section lists them all too. dig, a tool that asks DNS questions. Macs and most Linux machines have it; the script falls back to Route 53's own test tool without it.- Where you run things: your own machine, labeled (Your machine).
- Every output below is from a real run on November 10, 2026.
Two things here bill by the month, not the hour
A hosted zone is $0.50 a month, but nothing if you delete it within 12 hours of creating it. A web ACL is $5 a month plus $1 per rule, charged by the hour, so this lab's is about a cent. Forgotten, the pair is about $9 a month. Run delete the same evening; it tells you how long the zone existed.
The short version
- Registering a domain and hosting its DNS are different things. A hosted zone answers questions, but the world only asks it once the domain's registration points there.
- CloudFront is a content delivery network: copies of your site at hundreds of edge locations, with HTTPS included.
- An origin access control lets only CloudFront read the bucket, so nobody can go around it.
- Certificate Manager issues free certificates once you prove you control the name, by publishing a DNS record. For CloudFront they must be in us-east-1.
- WAF filters requests before they reach the site: your own rules, AWS's managed rule groups, and rate limits.
What this lesson costs
| Part | Cost |
|---|---|
| Route 53 hosted zone | $0.50 a month; nothing if deleted within 12 hours |
| DNS queries | $0.40 per million; queries for alias records pointing at AWS are free |
| CloudFront | Always free up to 1 TB and 10 million requests a month |
| Public certificates from Certificate Manager | $0 |
| WAF web ACL | $5 a month, plus $1 per rule and $0.60 per million requests, by the hour |
| S3, one small file | A fraction of a cent |
| This lesson | Under 5 cents, from credits |
| If it were left running | About $9 a month |
How a name becomes an address
Lesson 12's load balancer had a long AWS name, and Lesson 7's server only an IP address. Real shops have a name like shop.juniperandrye-lab.com. Turning that name into an address is the job of DNS (the Domain Name System), and the Networking track's DNS lesson covers it without AWS. The short version: your computer asks a resolver (your internet provider's, or a public one like 1.1.1.1), and the resolver asks a chain of servers, from the root, to the servers for .com, to the name servers for the domain itself, which hold the answer.
Two separate jobs make that chain work for a domain:
| Registering | Hosting the DNS | |
|---|---|---|
| What it is | Renting the name from the registry, through a registrar | Running the name servers that hold its records |
| What it decides | Which name servers the world asks | What they answer |
| In AWS | Route 53 Domains: about $15 a year for a .com | A Route 53 hosted zone: $0.50 a month |
| Elsewhere | Namecheap, Cloudflare, Squarespace and many more | Cloudflare, your registrar, your own servers |
You can register a name in one place and host its DNS in another. The link between them is a set of NS (name server) records at the registry: "for this name, ask these servers". This lesson doesn't register anything, which is the point of the diagram:
Is it allowed, and what does it cost?
(Your machine)
cd ~/Apps/aws-practice/lesson-14
chmod +x edge-lab.sh
./edge-lab.sh fence
== Is this allowed? (these services have no dry run, so this reads instead)
Route 53 (global) allowed
CloudFront (global) allowed
S3 in us-east-2 allowed
Certificate Manager in us-east-1 allowed
WAF for CloudFront, in us-east-1 allowed
== Is juniperandrye-lab.com free? The lab needs a name nobody owns
not registered: NXDOMAIN from the world's name servers
== What it costs
hosted zone: $0.50 a month, but nothing if deleted within 12 hours of creation
DNS queries: $0.40 per million; alias queries to CloudFront are free
CloudFront: always free up to 1 TB and 10 million requests a month
certificate (ACM): public certificates are free
WAF: $5 a month per web ACL and $1 per rule, by the hour: about 1 cent for this lab
S3: one small file: a fraction of a cent
this lab: under 5 cents, if delete runs within 12 hours
Route 53 and CloudFront are global services: they don't live in a Region. Two things that serve CloudFront do: its certificates and its firewall rules must be created in us-east-1, whichever Region the rest of your work is in. The new sign-up's free plan keeps you to one Region, so the fence checks us-east-1 specifically. It allowed both.
The fence also checks that nobody owns the lab's domain. NXDOMAIN, "no such domain", from the world's name servers means it isn't registered. Why that check exists comes next.
A hosted zone
In the console: Route 53 > Hosted zones > Create hosted zone, type Public hosted zone. Then Create record inside it.
(Your machine)
./edge-lab.sh dns
== A public hosted zone for juniperandrye-lab.com
== The zone's own name servers: Route 53 gave it four, in four different top-level domains
ns-1517.awsdns-61.org
ns-1631.awsdns-11.co.uk
ns-303.awsdns-37.com
ns-874.awsdns-45.net
== Adding records
juniperandrye-lab.com. MX 3600 10 mail.juniperandrye-lab.com
juniperandrye-lab.com. NS 172800 (made by Route 53)
juniperandrye-lab.com. SOA 900 (made by Route 53)
juniperandrye-lab.com. TXT 3600 "juniper-and-rye: fresh bread daily"
shop.juniperandrye-lab.com. A 300 192.0.2.10
www.juniperandrye-lab.com. CNAME 300 shop.juniperandrye-lab.com
== Asking the zone's own name server
shop.juniperandrye-lab.com, A:
192.0.2.10
www.juniperandrye-lab.com, CNAME:
shop.juniperandrye-lab.com.
juniperandrye-lab.com, MX:
10 mail.juniperandrye-lab.com.
== Asking the world (a public resolver, 1.1.1.1), the way a browser does
shop.juniperandrye-lab.com, A:
status NXDOMAIN
who answers for juniperandrye-lab.com (NS):
status NXDOMAIN
Route 53 gave the zone four name servers, in .org, .co.uk, .com and .net, so a problem with any one top-level domain can't take the zone down. It also made two records itself: NS, listing those four, and SOA (start of authority), the zone's housekeeping record. The lab added four more, one of each common kind, and asked a zone name server directly with dig @ns-303.awsdns-37.com. Each answered. Then it asked 1.1.1.1, the way any browser would, and got NXDOMAIN for both.
| Type | Holds | In the lab |
|---|---|---|
| A | An IPv4 address | shop to 192.0.2.10, an address set aside for documentation that goes nowhere |
| AAAA | An IPv6 address | None |
| CNAME | Another name: "ask about that name instead" | www to shop |
| Alias | Route 53's own kind: an A or AAAA record that follows an AWS resource's addresses | Next section |
| MX | The mail servers for the domain, with a priority | 10 mail.juniperandrye-lab.com |
| TXT | Any text: ownership proofs, email security settings | A note |
| NS and SOA | The zone's name servers and housekeeping | Made by Route 53 |
The number after each name is the TTL (time to live) in seconds: how long resolvers may keep the answer before asking again. 300 is five minutes. Before changing an important record, teams lower its TTL a day ahead, so the change spreads in minutes rather than hours.
A zone isn't ownership
The first run of this lab used juniperandrye.com. Route 53 created the zone without complaint and answered for it when asked directly. But the world's answers came back from a completely different set of name servers: that name is registered, to someone who isn't us, and the registry sends everyone to their name servers.
That's how it should be. Anyone can create a hosted zone for any name, including yours, and it does nothing, because the world only asks the name servers the registration points to. Control of a domain is control of its registration. That's also why the script now checks the domain first, and the lab uses juniperandrye-lab.com, a name nobody has registered.
CloudFront in front of a private bucket
CloudFront is AWS's CDN (content delivery network): it keeps copies of your site at edge locations, over 750 of them in cities around the world, and answers each visitor from one near them. Behind it is the origin, where the real files live: here, an S3 bucket. Lesson 15 covers S3 properly; for now it's a private folder holding one page.
| Part | What it does |
|---|---|
| Distribution | One CloudFront setup, with its own address like d3hmsajq4dhix7.cloudfront.net |
| Origin | Where CloudFront fetches what it doesn't have: a bucket, a load balancer, any web server |
| Cache behavior | Rules for a set of paths: which origin, HTTP or HTTPS, how long to keep copies |
| Origin access control (OAC) | CloudFront signs its requests to the bucket, and the bucket's policy allows only that one distribution |
| Price class | Which parts of the world's edge locations to use. The lab's, PriceClass_100, is North America and Europe. |
In the console: CloudFront > Distributions > Create distribution, pick the bucket as the origin, choose Origin access control settings, and let it update the bucket policy. Set Viewer protocol policy to Redirect HTTP to HTTPS.
(Your machine)
./edge-lab.sh cdn
== A private bucket, jr-lesson14-shop-42014c, in us-east-2 (Lesson 15 covers S3 properly)
== A CloudFront distribution in front of the bucket
E1JDQEX9AGOYYY: deploying to the edge locations (usually 3 to 6 minutes)
deployed after 181 seconds
== Its address: d3hmsajq4dhix7.cloudfront.net
== 1. Plain HTTP
HTTP/1.1 301 Moved Permanently
Server: CloudFront
Location: https://d3hmsajq4dhix7.cloudfront.net/
X-Cache: Redirect from cloudfront
X-Amz-Cf-Pop: IAD61-P2
== 2. HTTPS, first request
HTTP/2 200
server: AmazonS3
x-cache: Miss from cloudfront
x-amz-cf-pop: IAD61-P2
== 3. HTTPS, the same page again
HTTP/2 200
server: AmazonS3
x-cache: Hit from cloudfront
x-amz-cf-pop: IAD61-P2
== 4. Straight to the bucket, skipping CloudFront
HTTP/1.1 403 Forbidden
Server: AmazonS3
== The page
<!doctype html><title>Juniper & Rye</title>
<h1>Juniper & Rye</h1><p>Fresh from the oven, served from a CloudFront edge near you.</p>
== Before any firewall
/admin 403, from S3: the bucket said no
/?q=<script>alert(1)</script> 200
Four requests, read top to bottom:
| Request | Answer | What it shows |
|---|---|---|
| Plain HTTP | 301, to the HTTPS address | The redirect setting. CloudFront answered itself, without asking the bucket. |
| HTTPS, first | 200, Miss from cloudfront | The edge had no copy, so it fetched one from the bucket |
| HTTPS, again | 200, Hit from cloudfront | Served from the edge's copy, without touching the bucket |
| The bucket directly | 403 | The bucket only answers CloudFront, so nobody can go around it |
x-amz-cf-pop: IAD61-P2 names the edge location, the "point of presence", that answered. Edge locations are named after the nearest airport: IAD is Washington Dulles, the closest to the lab. HTTPS worked straight away, on CloudFront's own address, with CloudFront's own certificate. Your own name needs your own certificate, which is next.
Two more requests ran before any firewall existed, to compare with later. /admin got a 403 from S3, because there's no such file and the bucket won't say what it holds. The <script> one, an attempt to make a page run someone else's code, got a 200: nothing stopped it.
When a page changes, the edges keep their old copies until they expire. An invalidation tells them to drop them now: the first 1,000 paths a month are free.
Giving it a name
In the console: Route 53 > Hosted zones > the zone > Create record, turn on Alias, and choose Alias to CloudFront distribution. Then Certificate Manager, in US East (N. Virginia) > Request > Request a public certificate, with DNS validation, and Create records in Route 53.
(Your machine)
./edge-lab.sh name
== Pointing shop.juniperandrye-lab.com at CloudFront, with an alias record
shop.juniperandrye-lab.com, A, from the zone's own name server:
3.162.115.225
3.162.115.208
3.162.115.181
3.162.115.84
== Pretend the world asked our zone: connect to 3.162.115.225 as shop.juniperandrye-lab.com
curl: (60) SSL: no alternative certificate subject name matches target hostname 'shop.juniperandrye-lab.com'
subject: CN=*.cloudfront.net
subjectAltName does not match hostname shop.juniperandrye-lab.com
SSL: no alternative certificate subject name matches target hostname 'shop.juniperandrye-lab.com'
== Asking for a certificate for shop.juniperandrye-lab.com, in us-east-1
status: PENDING_VALIDATION
to prove you own shop.juniperandrye-lab.com, publish this record:
_bcd9c6f5878fad9bc30edd998b55bab6.shop.juniperandrye-lab.com. CNAME
-> _48cc852abd00d7557c3644376938504d.wzccmgtwzk.acm-validations.aws.
== Published it in our zone. Waiting 2 minutes for Certificate Manager to look
status: PENDING_VALIDATION
== Why: who does the world ask about juniperandrye-lab.com?
our zone's name servers:
ns-1517.awsdns-61.org
ns-1631.awsdns-11.co.uk
ns-303.awsdns-37.com
ns-874.awsdns-45.net
the world's answer:
status NXDOMAIN
the validation record, asked of the world:
status NXDOMAIN
Alias records
The lab replaced shop's A record with an alias to the distribution, and the zone now answers with four CloudFront addresses. An alias looks like an A record to the world, but Route 53 fills in the addresses itself and keeps up as CloudFront changes them. Compared with a CNAME:
| CNAME | Alias | |
|---|---|---|
| Points at | Any name, anywhere | AWS resources: CloudFront, load balancers, S3 websites, other records in the zone |
At the bare domain, juniperandrye-lab.com | Not allowed by the DNS rules | Allowed |
| Queries | Charged | Free, when it points at an AWS resource |
The middle row is the exam favorite: a bare domain, the "apex", can't be a CNAME, so pointing it at a load balancer or CloudFront needs an alias.
The wrong certificate
The lab then connected to a CloudFront address while calling itself shop.juniperandrye-lab.com, exactly as a browser would once the world could find the name. curl refused: the certificate CloudFront offered was for *.cloudfront.net, and a certificate is only good for the names written in it. A browser shows that as a full-page warning. CloudFront needs a certificate that names the shop, and it needs telling that the shop is one of its names.
A certificate that can't be issued
Certificate Manager (ACM) issues certificates for free and renews them on its own, but first you prove you control the name. With DNS validation, it gives you a CNAME record to publish, then looks it up the way the world would. The lab published the record, in our zone, and waited two minutes. Still PENDING_VALIDATION, and the end of the output shows why: Certificate Manager asked the world, the world found no such domain, and our zone was never asked.
That's the whole system working. If creating a zone were enough to get a certificate, anyone could get one for your bank's name. Proving control means proving the registration points at you. With a registered domain whose NS records point at the zone, the same record turns the certificate to ISSUED within minutes, and the rest is three settings on the distribution: the name under Alternate domain names, the certificate under Custom SSL certificate, and the alias record you already have.
For CloudFront, the certificate must be in us-east-1. A certificate for a load balancer must be in the load balancer's own Region. The exam asks about both.
A web application firewall
AWS WAF (web application firewall) looks at each request before CloudFront serves it, and allows, blocks or counts it. Lesson 9's security groups and network ACLs judge addresses and ports; WAF reads the request itself: its path, its query string, its headers, how often its sender has been asking.
| Part | What it does | The lab's |
|---|---|---|
| Web ACL | The set of rules, in priority order, attached to CloudFront, a load balancer or API Gateway | jr-lesson14-waf, allowing anything no rule blocks |
| Your own rule | Matches part of a request | block-admin: block any path starting with /admin |
| Managed rule group | Rules written and kept up to date by AWS, or sellers in AWS Marketplace | aws-common-rules: AWS's core rule set, for common attacks |
| Rate-based rule | Blocks any one address sending more than a limit in a time window | rate-limit: more than 10 a minute |
In the console: WAF & Shield > Web ACLs > Create web ACL, resource type Amazon CloudFront distributions, then Add rules. Or from the distribution: Security tab > Edit.
(Your machine)
./edge-lab.sh waf
== A web ACL for CloudFront, in us-east-1, with three rules
== Attaching it to the distribution
deployed after 121 seconds
== Trying to get past it
the home page 200
/admin 403, from WAF: blocked
/?q=<script>alert(1)</script> 403, from WAF: blocked
== One request a second, more than the 10 a minute the rate rule allows
after 16 seconds: 15 allowed, 0 blocked
after 32 seconds: 20 allowed, 10 blocked
after 32 seconds: 20 allowed, 10 blocked (first block at 22 seconds)
== What WAF saw, from its sample of the last 15 minutes
block-admin 1 BLOCK
aws-common-rules 1 BLOCK
rate-limit 1 BLOCK
jr-lesson14-waf 18 ALLOW
The same three requests as before the firewall. /admin is still a 403, but now WAF sent it, and the bucket never saw the request. The <script> request, a 200 before, was caught by AWS's managed rules, without anyone writing a rule for it. Telling the two kinds of 403 apart is why the script reads the page that comes back: S3's says AccessDenied, WAF's says Request blocked.
The rate limit isn't exact. It allows 10 requests a minute, yet 20 got through before the first block at 22 seconds. WAF counts requests and checks the totals every few seconds, so a burst gets a little past before the block lands. Rate rules stop floods, not the eleventh request.
The last section is WAF's sample of requests, not a count: it keeps a selection to show what each rule matched. Every rule shows up there, which is how you check a new rule matches what you meant. For full counts, WAF sends metrics to CloudWatch (Lesson 32), and full logs to a bucket or CloudWatch Logs.
And Shield
AWS Shield Standard protects every CloudFront distribution and Route 53 zone against the common network floods, DDoS (distributed denial of service) attacks, automatically and for free; nothing to switch on. Shield Advanced is $3,000 a month, for a year at a time, with a response team and cost protection during attacks. The free plan doesn't offer it, and a bakery doesn't need it.
Routing policies
The lab's records always give the same answer. Route 53 can choose the answer per question, and the Solutions Architect exam asks which policy fits which need. Described here, not built:
| Policy | Answers with | Fits |
|---|---|---|
| Simple | The same records, every time | One site, one place. The lab's. |
| Failover | The primary while its health check passes, the standby when it fails | A backup site in another Region (Lesson 19) |
| Weighted | Records in proportion: 90% one, 10% the other | Trying a new version on a few visitors |
| Latency | The Region with the lowest delay for that visitor | The same site in several Regions |
| Geolocation | By the visitor's country or continent | Language, or laws about where data may go |
| Geoproximity | By distance, with a dial to pull more visitors to one place | Shifting traffic between Regions gradually |
| Multivalue answer | Up to 8 healthy records, picked at random | Simple spreading, with health checks |
| IP-based | By the visitor's network address range | Sending one company's offices somewhere specific |
Health checks ($0.50 a month each, for AWS endpoints) are what make failover, multivalue and the others skip a broken answer. The lab doesn't make one, because it has nothing in a second Region to fail over to.
Take it down
In the console: CloudFront > the distribution > Disable, wait for it to finish deploying, then Delete. Then WAF & Shield > Web ACLs > Delete; Certificate Manager (us-east-1) > Delete; S3 > the bucket > Empty, then Delete; and Route 53 > the zone: delete every record but NS and SOA, then Delete zone.
(Your machine)
./edge-lab.sh delete
== Disabling the distribution and detaching the firewall (CloudFront takes a few minutes)
== Deleted distribution E1JDQEX9AGOYYY
== Deleted the origin access control
== Deleted web ACL jr-lesson14-waf
== Deleted the certificate request
== Deleted bucket jr-lesson14-shop-42014c
== Deleted the hosted zone for juniperandrye-lab.com
it existed for 13 minutes: under 12 hours, so it isn't charged
== Left over from this lab
hosted zones: 0
distributions: 0
web ACLs: 0
certificates: 0
buckets: 0
== Things that bill monthly, anywhere in the account
hosted zones: 0
CloudFront web ACLs: 0
CloudFront won't delete a distribution that's switched on. It has to be disabled first, and that change spreads to every edge location before the delete is allowed, which is most of this step's ten minutes. The firewall comes off in the same change, because a web ACL attached to anything can't be deleted. A hosted zone can't be deleted while it holds records of its own, so the script deletes those first, leaving the NS and SOA records Route 53 made.
By hand: every command the script runs
The same lab without the script, in order. It leaves out tags and waiting loops; SHOW=1 ./edge-lab.sh cdn prints the exact calls as they run. The JSON files are the ones the script writes; SHOW=1 shows their names. (Your machine)
export AWS_PROFILE=juniper-rye
DOMAIN=juniperandrye-lab.com
# A hosted zone, and records added with a change batch (a JSON list of changes)
ZONE=$(aws route53 create-hosted-zone --name "$DOMAIN" --caller-reference "lab-$(date +%s)" \
--query HostedZone.Id --output text)
aws route53 change-resource-record-sets --hosted-zone-id "$ZONE" --change-batch file://records.json
dig @ns-303.awsdns-37.com shop.$DOMAIN A # ask the zone's own name server
dig @1.1.1.1 shop.$DOMAIN A # ask the world
# A private bucket, one page, and an origin access control
BUCKET=jr-lesson14-shop-42014c
aws s3api create-bucket --bucket "$BUCKET" --region us-east-2 --create-bucket-configuration LocationConstraint=us-east-2
aws s3 cp index.html "s3://$BUCKET/index.html" --content-type text/html
OAC=$(aws cloudfront create-origin-access-control --origin-access-control-config \
Name=jr-lesson14-oac,SigningProtocol=sigv4,SigningBehavior=always,OriginAccessControlOriginType=s3 \
--query OriginAccessControl.Id --output text)
# The distribution, then a bucket policy allowing only it
DIST=$(aws cloudfront create-distribution-with-tags --distribution-config-with-tags file://dist.json \
--query Distribution.Id --output text)
aws s3api put-bucket-policy --bucket "$BUCKET" --policy file://policy.json
aws cloudfront wait distribution-deployed --id "$DIST"
curl -sI "https://$(aws cloudfront get-distribution --id "$DIST" --query Distribution.DomainName --output text)/"
# An alias record, and a certificate request (in us-east-1, for CloudFront)
aws route53 change-resource-record-sets --hosted-zone-id "$ZONE" --change-batch file://alias.json
CERT=$(aws acm request-certificate --region us-east-1 --domain-name "shop.$DOMAIN" --validation-method DNS \
--query CertificateArn --output text)
aws acm describe-certificate --region us-east-1 --certificate-arn "$CERT" \
--query 'Certificate.DomainValidationOptions[0].ResourceRecord'
# The firewall (also in us-east-1), attached by updating the distribution
aws wafv2 create-web-acl --region us-east-1 --scope CLOUDFRONT --name jr-lesson14-waf \
--default-action Allow={} --rules file://rules.json --cli-binary-format base64 \
--visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=jr-lesson14-waf
aws cloudfront get-distribution-config --id "$DIST" > current.json # set WebACLId, keep the ETag
aws cloudfront update-distribution --id "$DIST" --if-match "$ETAG" --distribution-config file://updated.json
# Taking it down, in this order
aws cloudfront update-distribution --id "$DIST" --if-match "$ETAG" --distribution-config file://disabled.json
aws cloudfront wait distribution-deployed --id "$DIST"
aws cloudfront delete-distribution --id "$DIST" --if-match "$NEW_ETAG"
aws cloudfront delete-origin-access-control --id "$OAC" --if-match "$OAC_ETAG"
aws wafv2 delete-web-acl --region us-east-1 --scope CLOUDFRONT --name jr-lesson14-waf --id "$ACL_ID" --lock-token "$LOCK"
aws acm delete-certificate --region us-east-1 --certificate-arn "$CERT"
aws s3 rb "s3://$BUCKET" --force
aws route53 change-resource-record-sets --hosted-zone-id "$ZONE" --change-batch file://delete-records.json
aws route53 delete-hosted-zone --id "$ZONE"
CloudFront changes are optimistic locking in action: every read returns an ETag, a version number, and every change must quote it. If someone changed the distribution in between, the update is refused instead of overwriting their change.
In real systems
- Every domain the business owns is registered in one place, locked against transfer, and set to auto-renew. An expired domain is a dead site and, worse, a name someone else can buy.
- Records pointing at deleted resources get cleaned up, or someone can claim the resource and serve their content on your name. It's called a subdomain takeover.
- Static sites are often just this: a private bucket, CloudFront, a certificate and an alias record, for pennies a month.
- Dynamic sites put CloudFront in front of the load balancer too, with WAF on the distribution, so attacks are stopped at the edge before they reach a server.
- New WAF rules start in Count mode, which logs what they would block without blocking it, until the team is sure they don't catch real customers.
- All of it is Terraform (Lesson 28), because a distribution's settings run to hundreds of lines.
Spot the problem
Work out what's wrong before you read the explanation.
"My certificate is issued, but CloudFront won't let me pick it." A team runs everything in us-east-2. They request a certificate for shop.example.com in Certificate Manager, validate it, and it shows ISSUED. In CloudFront's Custom SSL certificate list, it isn't there. What's wrong? CloudFront only uses certificates from us-east-1, whichever Region the rest of the work is in. The fix: request the certificate again in us-east-1, validate it with the same DNS record (it's usually identical), and pick that one. Then check: does curl -sI https://shop.example.com/ answer with no certificate error?
Keep this
| Remember | Why |
|---|---|
| Registering and hosting are separate | The registration decides which name servers the world asks |
| A zone isn't ownership | Anyone can make one; nobody asks it |
| Alias, not CNAME, at the bare domain | DNS forbids a CNAME there, and alias queries are free |
| Origin access control on the bucket | Nobody goes around CloudFront |
x-cache: Hit | Served from the edge, without touching the origin |
| Certificates for CloudFront: us-east-1 | Load balancers use their own Region's |
| Certificates are free, and validated by DNS | Proof of control, then automatic renewal |
| WAF reads requests; security groups read addresses | Different layers, use both |
| Delete the zone within 12 hours | Or it's $0.50 for the month |
Where you are now
The bakery has a DNS zone you've questioned directly and watched the world ignore, a page served over HTTPS from an edge location near you with a bucket nobody else can read, a certificate request that showed exactly what owning a name means, and a firewall that blocked an admin path, a script injection and a flood of requests. Part 2 is done. Next, Part 3 starts with Lesson 15, S3: the storage behind this lesson's page, its permissions, and what happens to files over time.
Check yourself
The lab's zone answered for shop.juniperandrye-lab.com, but 1.1.1.1 said NXDOMAIN. Why?
What does the second request's 'x-cache: Hit from cloudfront' tell you?
Why did the request straight to the bucket get a 403?
Why does the bare domain, juniperandrye-lab.com, need an alias rather than a CNAME to point at CloudFront?
The certificate stayed PENDING_VALIDATION even with its record in the zone. Why?
/admin got a 403 both before and after the firewall. What changed?
Which routing policy sends visitors to the standby site only when the main one fails its health check?
Key terms
- DNS (Domain Name System): turns names into addresses.
- Resolver: the server that asks the chain of name servers on your behalf.
- Registrar and registry: who you rent a domain through, and who keeps the list for its ending, like .com.
- Hosted zone: Route 53's container for one domain's records.
- Name server (NS) record: says which servers answer for a domain.
- TTL (time to live): how long an answer may be kept before asking again.
- Alias record: Route 53's A record that follows an AWS resource's addresses.
- CDN (content delivery network): copies of a site at locations around the world.
- Edge location: where CloudFront answers visitors from.
- Origin: where CloudFront fetches what it doesn't have.
- Origin access control (OAC): lets only one distribution read a bucket.
- Invalidation: telling the edges to drop their copies.
- ACM (AWS Certificate Manager): issues and renews certificates.
- DNS validation: proving control of a name by publishing a record.
- WAF (web application firewall): allows or blocks requests by their content and rate.
- Web ACL: a set of WAF rules attached to a resource.
- Managed rule group: rules written and maintained by AWS or a seller.
- Shield: AWS's DDoS protection; Standard is free and automatic.
Go deeper
- Networking track: DNS, TLS and HTTPS and What happens when you visit a site.
- AWS: Route 53 routing policies (opens in a new tab), choosing between alias and CNAME (opens in a new tab), and Route 53 pricing (opens in a new tab).
- AWS: restricting access to an S3 origin (opens in a new tab), certificate requirements for CloudFront (opens in a new tab), and AWS WAF rate-based rules (opens in a new tab).
- Try: run
fence,dnsandcdn, then upload a changedindex.htmlto the bucket withaws s3 cp. Reload the CloudFront address: you still get the old page, a cache Hit. Thenaws cloudfront create-invalidation --distribution-idwith the distribution's ID and--paths "/*", and reload. Rundeletewhen you're done.