{"id":"l-aws-1-2","courseId":"aws-cloud-foundations","lang":"en","kind":"lesson","summary":"Choose an AWS Region for a workload, explain how Availability Zones protect it from a data-centre failure, and say where edge locations fit in.","html":"<p>Lantern’s maintainers live in Lisbon and most of its users are in Portugal. When they create their first resource, the AWS console asks a question they have never had to answer: <strong>which Region?</strong> The old server sat in one data centre somewhere and nobody thought about it. On AWS, where your things run is a design decision, and it affects latency, law, resilience and your bill.</p>\n<h2 id=\"sec-1\" tabindex=\"-1\">Regions: where your data lives</h2>\n<p>A <strong>Region</strong> is a separate geographic area with its own copy of most AWS services. Each has a code you will type often: <code dir=\"ltr\">eu-west-1</code> is Ireland, <code dir=\"ltr\">eu-central-1</code> is Frankfurt, <code dir=\"ltr\">eu-south-2</code> is Spain, <code dir=\"ltr\">us-east-1</code> is North Virginia. Regions are isolated from each other. A bucket you create in <code dir=\"ltr\">eu-west-1</code> stores its data there, and AWS does not copy it to another Region unless you configure replication.</p>\n<p>You can list the Regions your account can use from the terminal (you install the CLI in lesson four):</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"bash\" data-index=\"0\"><div class=\"code-head\"><span class=\"code-title\">Terminal</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#953800;--shiki-dark:#FFA657\">aws</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> ec2</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> describe-regions</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --query</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> \"Regions[].RegionName\"</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --output</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> text</span></span></code></pre></div>\n<p>Not every service or feature launches in every Region at the same time, and prices differ between Regions. Some newer Regions are opt-in, so they do not appear until you enable them.</p>\n<h3 id=\"sec-2\" tabindex=\"-1\">How to choose</h3>\n<p>Use this order, and stop at the first rule that decides it:</p>\n<ol>\n<li><strong>Data rules.</strong> If a law or a contract says personal data stays in the EU, every non-EU Region is out.</li>\n<li><strong>Latency to users.</strong> Closer is faster. For Lantern, the Iberian and western European Regions are the candidates.</li>\n<li><strong>Service availability.</strong> Check that every service you plan to use exists in that Region.</li>\n<li><strong>Price.</strong> The same instance can cost noticeably more in one Region than another.</li>\n</ol>\n<p>Lantern ends up in a European Region close to Portugal. The exact choice matters less than making it on purpose and then using it consistently.</p>\n<h2 id=\"sec-3\" tabindex=\"-1\">Availability Zones: surviving a bad day</h2>\n<p>Inside each Region are <strong>Availability Zones</strong>. An AZ is one or more discrete data centres with redundant power, networking and cooling, physically separated from the other AZs in the Region, yet linked to them by fast, low-latency private fibre. Most Regions have three or more.</p>\n<p>The point of AZs is independent failure. A flood, fire or power cut in one AZ should not touch the others. So the rule for anything important is: <strong>run it in at least two AZs.</strong></p>\n<figure class=\"diagram\"><svg class=\"diagram-svg\" focusable=\"false\" viewBox=\"0 0 680 300\" role=\"img\" aria-labelledby=\"l-aws-1-2-t1\"><defs><marker id=\"arrow-l-aws-1-2-1\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0 L10 5 L0 10 z\" class=\"d-arrowhead\"/></marker></defs>\n  <title id=\"l-aws-1-2-t1\">One Region box holds three Availability Zone boxes, each with data centres, joined by low-latency links. Separate edge location circles near users are connected to the Region.</title>\n  <rect class=\"d-box\" x=\"20\" y=\"20\" width=\"440\" height=\"260\" rx=\"14\"/>\n  <text class=\"d-label-strong\" x=\"240\" y=\"48\" text-anchor=\"middle\">Region eu-west-1</text>\n  <rect class=\"d-box-primary\" x=\"40\" y=\"70\" width=\"120\" height=\"150\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"100\" y=\"96\" text-anchor=\"middle\">AZ a</text>\n  <rect class=\"d-box\" x=\"60\" y=\"112\" width=\"80\" height=\"34\" rx=\"6\"/>\n  <text class=\"d-label-muted\" x=\"100\" y=\"134\" text-anchor=\"middle\">DC</text>\n  <rect class=\"d-box\" x=\"60\" y=\"158\" width=\"80\" height=\"34\" rx=\"6\"/>\n  <text class=\"d-label-muted\" x=\"100\" y=\"180\" text-anchor=\"middle\">DC</text>\n  <rect class=\"d-box-primary\" x=\"180\" y=\"70\" width=\"120\" height=\"150\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"240\" y=\"96\" text-anchor=\"middle\">AZ b</text>\n  <rect class=\"d-box\" x=\"200\" y=\"112\" width=\"80\" height=\"34\" rx=\"6\"/>\n  <text class=\"d-label-muted\" x=\"240\" y=\"134\" text-anchor=\"middle\">DC</text>\n  <rect class=\"d-box-primary\" x=\"320\" y=\"70\" width=\"120\" height=\"150\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"380\" y=\"96\" text-anchor=\"middle\">AZ c</text>\n  <rect class=\"d-box\" x=\"340\" y=\"112\" width=\"80\" height=\"34\" rx=\"6\"/>\n  <text class=\"d-label-muted\" x=\"380\" y=\"134\" text-anchor=\"middle\">DC</text>\n  <rect class=\"d-box\" x=\"340\" y=\"158\" width=\"80\" height=\"34\" rx=\"6\"/>\n  <text class=\"d-label-muted\" x=\"380\" y=\"180\" text-anchor=\"middle\">DC</text>\n  <path class=\"d-line d-dashed\" d=\"M160 245 L320 245\"/>\n  <text class=\"d-label-muted\" x=\"240\" y=\"266\" text-anchor=\"middle\">low-latency private links</text>\n  <circle class=\"d-box-accent\" cx=\"560\" cy=\"70\" r=\"34\"/>\n  <text class=\"d-label\" x=\"560\" y=\"75\" text-anchor=\"middle\">Edge</text>\n  <circle class=\"d-box-accent\" cx=\"610\" cy=\"160\" r=\"34\"/>\n  <text class=\"d-label\" x=\"610\" y=\"165\" text-anchor=\"middle\">Edge</text>\n  <circle class=\"d-box-accent\" cx=\"560\" cy=\"245\" r=\"34\"/>\n  <text class=\"d-label\" x=\"560\" y=\"250\" text-anchor=\"middle\">Edge</text>\n  <path class=\"d-arrow\" d=\"M462 120 L522 82\" marker-end=\"url(#arrow-l-aws-1-2-1)\"/>\n  <path class=\"d-arrow\" d=\"M462 150 L572 158\" marker-end=\"url(#arrow-l-aws-1-2-1)\"/>\n  <path class=\"d-arrow\" d=\"M462 190 L524 236\" marker-end=\"url(#arrow-l-aws-1-2-1)\"/>\n</svg><figcaption>A Region contains isolated Availability Zones; edge locations sit outside, near users</figcaption></figure>\n<p>AZs have two kinds of label. The <strong>name</strong>, such as <code dir=\"ltr\">eu-west-1a</code>, is what you pick in the console. The <strong>AZ ID</strong>, such as <code dir=\"ltr\">euw1-az1</code>, always means the same physical zone in every account. In some older Regions, accounts created before November 2025 have names mapped independently, so your <code dir=\"ltr\">eu-west-1a</code> may be another team’s <code dir=\"ltr\">eu-west-1b</code>. When you coordinate with another account, compare AZ IDs:</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"bash\" data-index=\"1\"><div class=\"code-head\"><span class=\"code-title\">Terminal</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#953800;--shiki-dark:#FFA657\">aws</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> ec2</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> describe-availability-zones</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --region</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> eu-west-1</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> \\</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">  --query</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> \"AvailabilityZones[].{Name:ZoneName,Id:ZoneId}\"</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --output</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> table</span></span></code></pre></div>\n<p>This tells you which services are tied to what. <strong>Global</strong> services, such as IAM and CloudFront, are configured once for the whole account. <strong>Regional</strong> services, such as S3 buckets, Lambda functions and DynamoDB tables, live in one Region and AWS spreads them across AZs for you. <strong>Zonal</strong> resources, such as an EC2 instance or an EBS volume, live in exactly one AZ, and multi-AZ resilience is your job.</p>\n<h2 id=\"sec-4\" tabindex=\"-1\">Edge locations: closer than any Region</h2>\n<p>Regions are few. <strong>Edge locations</strong> are many: smaller sites in hundreds of cities that run Amazon CloudFront (the content delivery network) and Amazon Route 53 (DNS). When a visitor in Porto loads a Lantern poster, CloudFront can serve a cached copy from a nearby edge location instead of fetching it from the bucket every time. That is how Lantern will survive its next viral evening in section four.</p>\n<aside class=\"callout callout-mistake\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/></svg><span><span class=\"callout-kind\">Common mistake</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Building in whatever Region the console opened</span></p>\n<p>The console remembers the last Region you used, and on a new account that is often <code dir=\"ltr\">us-east-1</code>. People create a database there, then “lose” it after switching Regions, and pay for it for months. Pick Lantern’s Region, set it as the CLI default, and glance at the Region selector before every create.</p>\n</aside>\n<h2 id=\"sec-5\" tabindex=\"-1\">What geography costs</h2>\n<p>Data transfer is metered differently depending on where it goes. Traffic coming into AWS from the internet is generally free. Traffic between AZs in the same Region is charged per gigabyte, traffic between Regions costs more, and data sent out to the internet is charged too, which CloudFront can reduce through caching. You don’t need numbers to design well, only this habit: <strong>every arrow in your diagram that crosses an AZ or Region line has a price.</strong> Multi-AZ is worth paying for when downtime hurts; a cross-Region copy of everything usually isn’t, for a site Lantern’s size.</p>\n<p>Next you will see where AWS’s job ends and yours begins, and secure the account itself.</p>\n","toc":[{"id":"sec-1","text":"Regions: where your data lives","level":2},{"id":"sec-2","text":"How to choose","level":3},{"id":"sec-3","text":"Availability Zones: surviving a bad day","level":2},{"id":"sec-4","text":"Edge locations: closer than any Region","level":2},{"id":"sec-5","text":"What geography costs","level":2}],"takeaways":["A Region is an isolated geographic area such as eu-west-1, and your data stays in the Region you put it in unless you move it.","An Availability Zone is one or more separate data centres inside a Region; spreading a workload across two or more AZs survives the loss of one.","Edge locations are many smaller sites that cache and serve content close to users; Amazon CloudFront runs there.","Pick a Region by data rules first, then user latency, then service availability, then price.","Data moving between AZs, between Regions and out to the internet is metered, so architecture choices show up on the bill."],"further":[{"title":"AWS Regions and Availability Zones","url":"https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-availability-zones.html"},{"title":"What is a Region?","url":"https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html"},{"title":"AWS Global Infrastructure","url":"https://aws.amazon.com/about-aws/global-infrastructure/"}],"quiz":[{"q":"<p>Lantern’s database runs in one Availability Zone and that AZ loses power. What happens?</p>","options":[{"text":"AWS moves the database to another AZ automatically, whatever the setup.","why":"Only some configurations do this, such as an RDS Multi-AZ deployment. A single-AZ resource stays with its AZ."},{"text":"The whole Region goes offline, so a second AZ would not have helped.","why":"AZs are built to fail independently, with separate power and networking, so one AZ outage leaves the others running."},{"text":"The database is unavailable until the AZ recovers, because it lived in only one AZ.","why":"Correct. Resources such as an EC2 instance or an EBS volume are zonal; you get AZ resilience by running copies in more than one AZ."}],"answer":2},{"q":"<p>Lantern’s users are in Portugal and EU data rules apply to RSVP data. What should decide the Region first?</p>","options":[{"text":"The cheapest Region in the price list.","why":"Price matters, but a cheap Region that breaks a data rule or adds latency is a false saving. It comes last in the order."},{"text":"Whether the Region keeps the data where the rules require.","why":"Correct. Legal and contractual rules are hard constraints; latency, service availability and price are trade-offs you make inside them."},{"text":"Whichever Region the console opened in the first time.","why":"The default console Region is often us-east-1, which may be far from your users and outside your data rules."},{"text":"The Region with the most Availability Zones.","why":"Most Regions have at least three AZs, which is plenty for a site of Lantern’s size. It is not the first filter."}],"answer":1},{"q":"<p>You created an EC2 instance yesterday, but today the EC2 console shows no instances. What is the most likely explanation?</p>","options":[{"text":"The console is showing a different Region from the one you used yesterday.","why":"Correct. The EC2 console lists resources for the selected Region only. Check the Region selector in the top bar."},{"text":"AWS deletes idle instances after 24 hours on new accounts.","why":"AWS does not delete running instances for being idle. That is why forgotten resources keep costing money."},{"text":"Instances are global, so they appear under the Global tab.","why":"EC2 instances are zonal resources. Only a few services, such as IAM and CloudFront, are global."}],"answer":0},{"q":"<p>Where does Amazon CloudFront serve cached copies of Lantern’s posters from?</p>","options":[{"text":"From the Availability Zone that holds the S3 bucket.","why":"That is the origin. CloudFront exists to avoid sending every request back there."},{"text":"From edge locations close to each viewer.","why":"Correct. Edge locations are far more numerous than Regions, so a cached poster travels a short distance to the browser."},{"text":"From a second Region that you must choose when you create the bucket.","why":"CloudFront does not need you to pick extra Regions; it uses its global network of edge locations."}],"answer":1}],"exercise":{"kind":"choice","multiple":false,"options":["us","eu-cheap-missing","eu-near","eu-far"],"correct":["eu-near"],"title":"Pick Lantern's Region","prompt":"<p>Lantern must keep RSVP data (names and emails) inside the EU, most visitors are in Portugal, and the plan uses Amazon S3, Amazon CloudFront, AWS Lambda, Amazon API Gateway and Amazon DynamoDB. You have four candidate Regions with these made-up properties. Apply the order from the lesson (data rules, latency, service availability, price) and choose one.</p>\n","hints":["Cross out every candidate that fails a hard rule before comparing anything else.","A Region that is missing a service you need is not cheaper; you would have to redesign or run that part elsewhere.","Among the Regions left, prefer the one nearest the users. A small price difference rarely beats latency for a public website."],"explanation":"<p>The US Region fails the data rule, so it is out no matter how cheap or complete it is. The cheapest EU Region lacks a service in the plan, which would force a redesign. Of the two EU Regions with everything you need, the one nearest Portugal gives visitors lower latency, and the small price gap does not outweigh that. Notice that CloudFront would serve cached files from edge locations anyway, but the API calls to Lambda and DynamoDB still travel to the Region, so its distance matters for every RSVP.</p>\n","checkLabels":{},"optionText":{"us":{"text":"A US Region: every service available, lowest prices, default in the console.","why":"It fails the first and hardest rule. RSVP data must stay in the EU, so nothing else about this Region matters."},"eu-cheap-missing":{"text":"An EU Region about 1,500 km away: cheapest in the EU, but Amazon API Gateway is not offered there yet.","why":"It passes the data rule but fails service availability. Saving a little on price is not worth redesigning the API."},"eu-near":{"text":"An EU Region about 500 km from Lisbon: every planned service available, prices a few percent above the cheapest EU Region.","why":"Correct. It meets the data rule, is closest to the users and has every service. A few percent on price is the least important factor."},"eu-far":{"text":"An EU Region about 2,500 km away: every planned service available, same prices as the nearest Region.","why":"It is valid, but it is further from users for no gain. Each API call pays the extra distance in latency."}}},"words":775,"readMinutes":4}