ZAAWS Zero to Architect

Chapter 4 · Part 1: Cloud and AWS Foundations

Your Safe AWS Playground

About 40 min read

Goal: create your AWS account the way a professional does, lock it down before you build anything, put a spending alarm in place, learn the console, CloudShell and the AWS CLI, and build the habits (tags, names, cleanup) that keep labs cheap and tidy for the rest of the course.
Reading time: about 55 minutes. Lab time: 45 minutes. Lab cost: about $0.
How to read this chapter: read it, then do the lab in section 4.9 straight away. This is the one chapter where doing matters more than reading. Go Deeper boxes are optional.
Version note: AWS changed its free tier in July 2025 and keeps improving sign-in and billing screens. This chapter was checked against AWS documentation in December 2026. Screens may move around, but the ideas and the order of steps stay the same.

What You Will Be Able to Do After This Chapter#

  • Create an AWS account, secure the root user with MFA, and say why you never use root for daily work.
  • Explain the Free plan, credits and "always free" offers, and what is not free.
  • Create a budget with email alerts, and explain why a budget alert is a smoke alarm, not a sprinkler.
  • Move around the console, open CloudShell, install the AWS CLI v2, and sign in from it without long-lived keys.
  • Name and tag resources so you can find them, and so you can delete them later.
  • Do the same task six ways (console, CLI, CloudShell, SDK, infrastructure as code, raw API) and explain that all six are the same API underneath.
  • Name the 25 services that appear in most real architectures and say what each one is for.
  • Run a cleanup routine that finds forgotten resources in every Region.

The Big Picture: Moving Into a New Apartment#

Opening an AWS account is like moving into a new apartment where the landlord lets you build anything, and charges by the hour. A sensible tenant does five things on day one.

Day-one taskApartment analogyAWS step
1. Lock the master key awayPut the landlord's master key in a safe, and use a normal door keySecure the root user with MFA, then stop using it
2. Make your daily keyCut a key that opens your door, not every door in the buildingCreate an admin identity for daily work
3. Install a smoke alarmYou want a loud warning before the fire is bigCreate a budget with alerts
4. Learn where the switches areFind the fuse box, the water valve and the light switchesLearn the console, CloudShell and CLI
5. Label everything and tidy upName the boxes, and take the rubbish out every eveningTags, names and a cleanup routine
   YOU  --(email + password + MFA)-->  ROOT USER  (all powers, locked away, used almost never)
    |
    |  creates once
    v
   ADMIN IDENTITY  (daily work, MFA on)  --> builds labs --> tags everything --> cleans up daily
                                                   |
                                                   +--> BUDGET watches the bill and emails you

The whole chapter in 60 seconds: sign up, then immediately turn on MFA for the root user, add alternate contacts, and create a separate admin identity for daily work. Never create access keys for root. Pick the Free plan while learning: you get up to $200 in credits for 6 months and no surprise charges, but free is not unlimited, and services such as NAT gateways, load balancers and big databases burn credits fast. Create a budget with email alerts first (it warns, it does not stop spending). Use the console to explore, CloudShell for zero-setup commands, and the CLI with aws login or SSO on your laptop. Everything you click is an API call. Tag every lab resource (Lab=ch04) and delete it the same day.

Jargon Buster#

TermPlain meaning
AWS accountA container for all your resources and your bill, with a 12-digit account ID. It is the basic security and billing boundary.
Root userThe identity created with the account, using the sign-up email. It has unlimited power and cannot be restricted. Protect it, then leave it alone.
IAM user / identityA person or program you create inside the account, with only the permissions you give. (Chapter 6.)
MFAMulti-factor authentication: a password plus something you have (a phone app, a security key or a passkey).
Free plan / creditsA starter offer for new accounts: credits that pay for usage, for a limited time.
BudgetA spending limit you define, which sends alerts when real or forecast spend crosses a threshold.
ConsoleThe AWS website where you click to manage resources.
CLICommand Line Interface: a program (aws) that lets you control AWS by typing commands.
CloudShellA free terminal inside the console, already signed in, with the CLI installed.
SDKSoftware Development Kit: a code library (for Python, JavaScript, Java and more) to call AWS from programs.
Access keyA long-lived ID and secret pair for programs. Powerful, easy to leak, best avoided. Prefer temporary credentials.
ProfileA named set of CLI settings (Region, sign-in method), so you can switch between accounts easily.
TagA label (key and value) you attach to a resource, for finding it, grouping it and tracking its cost.
ARNAmazon Resource Name: the unique "full address" of any resource.
QuotaA limit on how many of something you may create (also called a service limit).

4.1 Creating an Account the Right Way#

The sign-up steps#

  1. Choose an email you will keep for years. This becomes the root user's login and the place password-reset mail goes. Use a mailbox you control with its own strong password and MFA, not a throwaway address. For a company, use a shared mailbox such as aws-root@yourcompany.com so the account does not depend on one person.
  2. Pick an account name (for example stackcafe-learning) and verify the email with the code AWS sends.
  3. Set a long, unique root password (a password manager helps).
  4. Add contact details (personal or business).
  5. Add a payment method. AWS needs a valid card even for the Free plan.
  6. Verify your identity by phone (a text message or a call).
  7. Choose the plan: start with the Free plan (see 4.2), and the Basic support plan (free).

Immediately after sign-up: lock the root user#

The root user can do everything: close the account, change the payment method, remove any protection you add. It cannot be limited by IAM policies. If someone steals the password, they own your account and your bill. So you do four things, in this order, before anything else:

#ActionWhereWhy
1Turn on MFA for root, using a passkey or security key, or an authenticator app. Register a second MFA device as a backupConsole: account menu, then Security credentialsStops a stolen password from being enough. AWS now expects MFA on root users
2Add alternate contacts for billing, operations and securityAccount menu, then AccountAWS can reach the right person with cost, outage or abuse notices
3Never create access keys for root, and delete any that existSecurity credentialsRoot keys are the most dangerous secret in AWS
4Create an admin identity for daily work, then stop using rootIAM (this chapter's lab), IAM Identity Center (Chapter 7)Everyday work should never run with unlimited power

Also set now (two minutes each)#

  • Account alias: a friendly sign-in name such as stackcafe-learning instead of the 12-digit ID.
  • IAM access to billing: by default only root can open the Billing pages. Turn on IAM user and role access to Billing information so your admin identity can see costs, so you do not need root for that.
  • Free tier usage alerts: in Billing preferences, switch on alerts so AWS emails you when you approach free limits.

MFA ranking, strongest first: a hardware security key or passkey (it cannot be phished), then an authenticator app (a code that changes every 30 seconds), then SMS (avoid, where AWS offers a choice). Keep your backup device somewhere different from your first one.

"It is just my practice account, so root is fine." Attackers scan for leaked keys all day, and a compromised practice account is used to mine cryptocurrency on your card within minutes. The habits you build now are the habits you take to a real job. Do it properly from day one.

Go DeeperWhat only the root user can do (the short, rare list)

A small set of tasks still needs the root user. You will do them rarely, then lock root away again.

  • Change the account name, root email address or root password.
  • Close the AWS account.
  • Change or cancel the AWS Support plan, and restore IAM permissions if every admin is locked out.
  • A few special tasks: for example, configure an S3 bucket policy that blocks all access, or sign up for GovCloud. (AWS publishes the full list in the IAM documentation under "Tasks that require root user credentials".)

In a company you also protect the root email address and phone number, because whoever controls them can take over the account through a password reset. That is why they should be shared, monitored mailboxes and numbers, not one person's.

Go DeeperPreview: why real companies use many accounts

One account is fine for learning. Companies use many: one for production, one for testing, one for security logs, one per team. Accounts are the strongest wall in AWS: a mistake or breach in one does not spill into another. Chapter 8 covers AWS Organizations and Control Tower, and Chapter 7 shows how people sign in to many accounts with a single login. For now, remember that "account" is a boundary, not just a login.

4.2 The Free Tier and Credits: What Is Free and What Is Not#

AWS gives you three kinds of free usage. Knowing which is which prevents most surprise bills.

KindWhat it isExampleLasts
Free plan credits (new accounts)Credits that pay for usage. You get $100 at sign-up and can earn up to $100 more by trying key services, so up to $200 in totalLaunch an EC2 instance, and the hours are paid from creditsThe Free plan ends after 6 months or when the credits run out, whichever comes first. Credits must be used within 12 months of account creation
Always free offersSmall monthly allowances that never expireFor example Lambda: 1 million requests a month. SQS and SNS have a free million requests too. (Check the Free Tier page for the current list.)Forever, per month
Short trialsTime-limited trials of specific servicesA few weeks of a particular serviceDays or weeks

Accounts created before July 2025 may still be on the older "12 months free" model. This course assumes a new account.

Free plan or Paid plan?#

Free planPaid plan
Starting creditsUp to $200The same credit offer
Can I be charged?No. When credits or 6 months run out, the plan ends and you must upgrade to continueYes, after credits are used. Credits still apply first
Services availableMost services. Some services and features are limitedAll services
Best forLearning, with a built-in spending safety netProduction, or labs that need restricted services

Recommendation: start on the Free plan. It cannot surprise you. Upgrade only when you deliberately need more. Even then, your remaining credits are applied to your bill first.

What eats your credits quickly#

Credits are real money to AWS, so these items drain them. Each lab tells you which of these it creates.

ServiceWhy it costs even when idleRough size (check pricing)
NAT gatewayHourly charge plus a charge per GB processedAbout $30 to $45 a month if left on
Load balancer (ALB, NLB)Hourly charge while it existsAbout $16 and up a month
EKS control planeHourly charge per clusterAbout $72 a month
Public IPv4 addressEvery public IPv4 address is charged by the hour, even attached to a stopped serverAbout $3.60 a month each
RDS and Aurora databasesInstance hours, storage and backupsFrom a few dollars up to hundreds a month
EBS volumes and snapshotsCharged per GB even when no server is attachedCents per GB a month
Data transfer out to the internetPer GB after a small free allowanceAround $0.09 per GB

"Free tier means unlimited and automatic." It means limited allowances and credits. Launching a big instance, a NAT gateway, or leaving a database running can use up your whole credit balance in days. Also, "stopped" is not "deleted": a stopped server still pays for its disk and its public IP.

4.3 Budgets and Alerts: Install the Smoke Alarm First#

AWS Budgets lets you define how much you plan to spend, and emails you when actual or forecast spend crosses a percentage of it. It is the first thing to create in any new account.

AlertTypeMeaning
50 percent of the budgetActual"You are halfway. Is that expected?"
80 percent of the budgetActual"Look now."
100 percent of the budgetForecast"At this pace you will pass your limit. Act before it happens."

Create it in the console#

  1. Open Billing and Cost Management, then Budgets, then Create budget.
  2. Choose Use a template, then Monthly cost budget.
  3. Enter an amount you are comfortable with (for example $10 for learning) and your email address.
  4. Create it. The template adds a sensible alert for you.
  5. Open it afterwards and add the 50 percent and 100 percent forecast alerts from the table above.

Or create it with the CLI (a first taste of infrastructure as code)#

# budget.json
{
  "BudgetName": "monthly-learning-budget",
  "BudgetLimit": { "Amount": "10", "Unit": "USD" },
  "TimeUnit": "MONTHLY",
  "BudgetType": "COST"
}

# notifications.json
[
  {
    "Notification": {
      "NotificationType": "ACTUAL",
      "ComparisonOperator": "GREATER_THAN",
      "Threshold": 80,
      "ThresholdType": "PERCENTAGE"
    },
    "Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "you@example.com" }]
  }
]

# create it (replace the account ID)
aws budgets create-budget \
  --account-id 123456789012 \
  --budget file://budget.json \
  --notifications-with-subscribers file://notifications.json

Three more cost tools to know (more in Chapter 5)#

ToolWhat it does
Cost ExplorerGraphs of your spend by service, Region, tag and day. Turn it on the first day, because history only starts when you enable it
Cost Anomaly DetectionLearns your normal spending and emails you when something suddenly jumps
Billing and Cost Management homeMonth-to-date spend, forecast and free-tier usage in one view

A budget alert does not stop anything. It is an email, not a circuit breaker. Billing data also arrives with a delay of several hours, sometimes up to a day, so a runaway resource can burn money before the email lands. The only real protection is the combination: Free plan, small labs, daily cleanup, and alerts you actually read. (Budget actions can attach a restrictive policy automatically, which Chapter 5 shows.)

Your first two or three budgets are free or nearly free. Check the Budgets pricing page for the current allowance. Never skip the alarm to save pennies.

4.4 Console Tour, CloudShell, AWS CLI v2 and Named Profiles#

The console in one picture#

 +------------------------------------------------------------------------------------------+
 | [aws logo]  [ Services ] [ Search: "type a service or feature" ]  [>_ CloudShell] [bell]    |
 |                                          [ Mumbai v ] <- REGION     [ account name v ]      |
 +------------------------------------------------------------------------------------------+
 |  Console home                                                                              |
 |   Recently visited  |  Cost and usage  |  Health  |  Applications / resources             |
 +------------------------------------------------------------------------------------------+
   Search bar    = fastest way to any service (type "ec2", "s3", "iam")
   >_ icon       = opens CloudShell, a free terminal in your browser
   Region menu   = which Region you are looking at. CHECK IT FIRST, ALWAYS (Chapter 3)
   Account menu  = account ID, security credentials, billing, sign out
HabitWhy
Glance at the Region menu before you click anythingMost "my resource disappeared" stories are a wrong Region
Use the search bar instead of menusIt is quicker and survives menu redesigns
Star or pin your favorite servicesSaves clicks
Read the pricing note on create screensMany screens show an estimate

CloudShell: a ready terminal with no setup#

AWS CloudShell is a browser-based terminal that opens from the >_ icon. It is already signed in as you, with the AWS CLI, Python, Node.js, Git and jq installed. It is free, and it keeps a small home directory (about 1 GB) per Region between sessions. It is perfect for learning because nothing needs installing, and there are no credentials on your laptop to lose.

Good forNot for
Running CLI commands from the labs, quick scripts, checking thingsLong-running jobs (sessions time out when idle)
Working without installing anythingHeavy development. Use your own laptop and editor

Install the AWS CLI v2 on your own computer#

# Linux (x86_64)
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
unzip awscliv2.zip && sudo ./aws/install

# macOS: download and run the official .pkg installer from the AWS CLI documentation
# Windows: download and run the official .msi installer from the AWS CLI documentation

aws --version        # confirm it works. It should say aws-cli/2.x

Signing in from the CLI without long-lived keys#

The old way was to create an access key and paste it into aws configure. It works, but a key that never expires is a leak waiting to happen. Today there are better options. Use them in this order.

RankMethodHowCredentials
1IAM Identity Center (SSO)aws configure sso, then aws sso login (Chapter 7)Temporary, centrally managed. Best for teams
2aws login with your console sign-inRun aws login, sign in in the browser. (Add --remote if you work on a machine without a browser)Temporary, refreshed automatically. Great for a single learner account
3CloudShellNothing to do. Already signed inTemporary
4 (avoid)IAM user access keysaws configureLong-lived. Only for tools that cannot do anything else, and rotate them

Both aws login and SSO need a recent version of the CLI v2. If the command is not found, update the CLI.

Named profiles: one laptop, many accounts#

The CLI stores settings in ~/.aws/config. A profile is a named block, so you can switch between accounts, roles and Regions without retyping anything.

# ~/.aws/config
[default]
region = ap-south-1
output = json

[profile stackcafe-learning]
region = ap-south-1
output = table
aws sts get-caller-identity                              # WHO AM I? Shows account ID and identity
aws sts get-caller-identity --profile stackcafe-learning # the same, using a named profile
export AWS_PROFILE=stackcafe-learning                    # use that profile for this terminal session
aws ec2 describe-regions --output table                  # --output: json, table, text
aws ec2 describe-regions --query "Regions[].RegionName"  # --query filters the answer (JMESPath)

The command to run when confused: aws sts get-caller-identity. It prints the account ID and identity you are using right now. Half of "access denied" and "wrong account" mysteries end the moment you run it.

Go DeeperWhere does the CLI look for settings? (the order matters)

When you run a command, the CLI picks settings in this order, from strongest to weakest:

  1. Command-line options, such as --region and --profile.
  2. Environment variables, such as AWS_REGION and AWS_PROFILE.
  3. The profile in ~/.aws/config (and the shared credentials file).
  4. Container or instance credentials, for code running on AWS (a Lambda role, an EC2 instance role).

This is why a script that works on your laptop can behave differently in CI or on a server: a stray environment variable beats your profile. When in doubt, run aws configure list to see which source won.

4.5 Regions, Tagging and Naming Conventions That Save You Later#

Pick one Region and stick to it#

Remember from Chapter 3: resources live in a Region. Set your default Region once (ap-south-1 for this course) in the console, in your CLI profile and in your tools. Mixing Regions is the number one cause of "I cannot find it".

A naming convention#

Good names make a list readable and let you search. A simple pattern:

   <app>-<environment>-<what>-<optional number>

   stackcafe-dev-web-01        a web server in the dev environment
   stackcafe-prod-orders-db    the production orders database
   stackcafe-lab-ch04-bucket   a throwaway lab bucket for Chapter 4

Rules: lowercase letters, digits and hyphens. No spaces or personal names. Some resources, such as S3 buckets, need globally unique names, so add your account ID or a random suffix.

Tags: the labels that run your cloud#

A tag is a key and value attached to a resource. Tags do four jobs: find things, group them, allocate cost (see what each project spends) and control access (in advanced policies). Use a small, fixed set of keys.

Tag keyExample valuePurpose
ProjectstackcafeWhich product it belongs to
Environmentdev, test, prodWhat stage it serves
Ownermaya@stackcafe.exampleWho to ask, and who gets the bill
CostCenter1234Finance grouping
Labch04Course helper: find and delete everything from one lab in one search
  • Tag keys are case-sensitive: Project and project are different. Pick one style and keep it.
  • For tags to appear in cost reports you must activate them as cost allocation tags in the Billing console. Tags only start counting after activation.
  • Not every resource supports every tag action, but nearly all do. Tag as you create.

ARN: the full address of any resource#

Every resource has a unique ARN. You will see ARNs in every permission policy.

   arn : aws : s3 : : : my-bucket/menu.png          an S3 object (no Region or account in the ARN)
   arn : aws : ec2 : ap-south-1 : 123456789012 : instance/i-0abc123
    |     |     |        |              |                |
    |     |     |        |              |                +-- the resource type and ID
    |     |     |        |              +------------------- the 12-digit account ID
    |     |     |        +---------------------------------- the Region (blank for global resources)
    |     |     +------------------------------------------- the service
    |     +------------------------------------------------- the partition (aws, aws-cn, aws-us-gov)
    +------------------------------------------------------- always "arn"

StackCafe rule: every resource Maya creates gets Project=stackcafe, Environment=... and Owner=.... In Chapter 8 she will make this mandatory with a policy, so an untagged resource simply cannot be created. Start the habit now, while it is free.

4.6 Six Ways to Talk to AWS (and the One Truth Underneath)#

You can control AWS in six ways. They look different, but every one of them ends the same way: an HTTPS API call, signed with your credentials, checked by IAM, then executed by the service.

  Console (click)  --+
  CLI (type)       --+
  CloudShell       --+--->  AWS API endpoint  --->  IAM checks "is this allowed?"  --->  the service does it
  SDK (code)       --+      (HTTPS + signature)      (Chapter 6)                          (create, change, delete)
  IaC (templates)  --+
  Raw HTTPS call   --+

One task, six ways: create a storage bucket#

WayWhat you doBest for
1. ConsoleOpen S3, click Create bucket, type a name, pick the RegionExploring, learning, one-off checks
2. CLIOne command (below)Quick tasks, scripts, repeatable steps
3. CloudShellThe same command, in the browser terminalZero-setup CLI
4. SDKA few lines of Python or JavaScript inside your applicationApps that need AWS at run time
5. Infrastructure as codeA template that describes the bucket, deployed as a stackReal environments: repeatable, reviewable, deletable in one go (Chapter 34)
6. Raw APISend a signed HTTPS request yourselfAlmost never. It shows what the others do for you
# 2 and 3. CLI (works in CloudShell too)
aws s3api create-bucket \
  --bucket stackcafe-lab-ch04-123456789012 \
  --region ap-south-1 \
  --create-bucket-configuration LocationConstraint=ap-south-1
# 4. SDK (Python, library name: boto3)
import boto3

s3 = boto3.client("s3", region_name="ap-south-1")
s3.create_bucket(
    Bucket="stackcafe-lab-ch04-123456789012",
    CreateBucketConfiguration={"LocationConstraint": "ap-south-1"},
)
# 5. Infrastructure as code (CloudFormation)
Resources:
  LabBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: stackcafe-lab-ch04-123456789012
      Tags:
        - { Key: Lab, Value: ch04 }

The learning path inside this course: click in the console first to see what exists, then repeat the same thing with the CLI to see the parameters, and from Chapter 34 write it as code. The console teaches you the concepts. The code makes it repeatable. A professional ends up mostly in code.

Go DeeperWhat a raw API call looks like (and why signing matters)

Every request to AWS carries a signature (called Signature Version 4) computed from your secret key, the request and the time. AWS recalculates it, and if it matches, it knows who sent it and that the request was not altered. The CLI and SDKs do this for you.

The idea is the key to security: your secret key never travels. Only a signature does, valid for minutes. That is also why temporary credentials are safer. A stolen signature expires in minutes. A stolen long-lived key works until someone notices.

4.7 The Service Map: 25 Services That Cover 90 Percent of Real Designs#

AWS has more than 200 services, which overwhelms beginners. The truth is that most architectures use a small core. Learn these 25 first. Every one has its own chapter later, so this is a preview map, not an exam.

GroupServiceOne-line jobEveryday comparisonChapter
Compute (where code runs)EC2Virtual servers you manageA rented empty flat15, 16
LambdaRun a function when something happensA vending machine that cooks one slice17
ECS and FargateRun containers, with no servers to manage on FargateShipping containers, with a port crew provided18
EKSKubernetes, managedA big container terminal with its own rules19
Storage (where files live)S3Unlimited object storageAn endless warehouse with labeled boxes21
EBSA disk for one serverA hard drive22
EFSA shared network folderA shared office drive22
Databases (where records live)RDS and AuroraManaged relational (SQL) databasesA well-run filing office24
DynamoDBServerless key-value databaseA giant lightning-fast index-card box25
ElastiCacheIn-memory cacheA sticky note on the desk26
Networking and edge (how things connect)VPCYour private networkA gated neighborhood10, 11
Route 53DNS: names to addressesA phone book13
CloudFrontGlobal content delivery and cacheLocal shops stocking popular goods13
Elastic Load BalancingSpreads traffic across serversA restaurant host seating guests14
API GatewayA managed front door for APIsA reception desk28
Security and identity (who and what is protected)IAMWho may do whatBuilding access badges6
KMSCreate and control encryption keysA locksmith and a key safe9
WAFBlock bad web requestsA bouncer38
Integration (how parts talk)SQSA queue of messagesA ticket line29
SNSBroadcast a message to manyA loudspeaker29
EventBridgeRoute events between servicesA smart switchboard29
Management and operations (running it well)CloudWatchMetrics, logs and alarmsA dashboard and smoke alarm36
CloudTrailA record of every API callA security camera log36
CloudFormationBuild infrastructure from templatesArchitectural blueprints34
OrganizationsManage many accounts togetherA company holding many offices8

All 25 in one picture: StackCafe, fully grown#

  customers --> Route 53 (name) --> CloudFront (cache) --> WAF (filter)
                                          |
                          +---------------+----------------+
                          |                                |
                    S3 (static site)           API Gateway or ALB (front door)
                                                           |
                                         +-----------------+-----------------+
                                         |                 |                 |
                                      Lambda          ECS/Fargate           EC2  (compute)
                                         |                 |                 |
                    +--------------------+--------+--------+---------+-------+
                    |                             |                  |
              DynamoDB / RDS                 ElastiCache            S3 (files; EBS/EFS disks)
              (records)                      (speed)                (storage)
                    ^
   SQS / SNS / EventBridge  (messages between parts)           all inside a VPC (private network)

   Watching and governing everything:  IAM (who) | KMS (keys) | CloudWatch + CloudTrail (see) |
                                       CloudFormation (build) | Organizations (accounts)

How to use this map: do not memorize it. Return to it when a new chapter starts, and find where that service sits. After a few chapters the map becomes second nature, and new services will slot into it easily, because they all answer one of four questions: where does it run, where does the data live, how do the parts talk, and who is allowed.

4.8 Cleaning Up: How to Never Get a Surprise Bill#

Cloud bills rarely come from big mistakes. They come from forgotten small things running for weeks. A tidy routine fixes this.

The usual suspects#

Forgotten itemWhy it keeps costingHow to find it
Running EC2 instancesBilled every second they runEC2 console in each Region, or the CLI loop below
Unattached EBS volumes and old snapshotsBilled per GB even with no serverEC2, then Volumes, filter by "available"
NAT gatewaysHourly plus data chargesVPC console, then NAT gateways
Load balancersHourly while they existEC2, then Load Balancers
Public IPv4 addresses and Elastic IPsHourly per addressEC2, then Elastic IPs and Network Interfaces
RDS and Aurora databasesInstance and storage charges. A stopped RDS instance starts itself again after about 7 daysRDS console
EKS clustersHourly control planeEKS console
S3 buckets with data, CloudWatch logsStorage per GBS3 console, CloudWatch Log groups

Five habits#

  1. Tag every lab resource with Lab=chNN, so you can find them with one search (Resource Groups and Tag Editor).
  2. Delete in reverse order of creation. Things with dependencies (a server in a subnet in a VPC) must be removed from the inside out.
  3. Prefer templates. If a lab was created with CloudFormation, deleting the stack removes everything in it.
  4. Do the end-of-day check: look at Cost Explorer for today, and run the sweep script below.
  5. Check every Region you used, not just the one the console is showing.

A sweep script: find running servers in every Region#

for r in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do
  aws ec2 describe-instances --region "$r" \
    --query "Reservations[].Instances[?State.Name!='terminated'].[InstanceId,InstanceType,State.Name]" \
    --output text | sed "s/^/$r  /"
done

# Disks not attached to anything (still billing):
aws ec2 describe-volumes --region ap-south-1 \
  --filters Name=status,Values=available \
  --query "Volumes[].[VolumeId,Size]" --output text

No output means nothing is running. Anything listed is a cost you can still delete.

The nuclear option: if you are done with the account entirely, closing it (from the root user) stops all charges. AWS keeps a short recovery period after closure. It is the cleanest end to a learning account, but you will lose everything in it.

"I deleted the server, so I am done." Deleting an instance does not delete the EBS volume if it was configured to stay, its snapshots, its Elastic IP, its load balancer or its logs. Check the whole list above, not only the thing you remember.

Architect Decisions: Setting Up Safely#

DecisionChooseWhy
Who signs in for daily work?An admin identity (IAM Identity Center for teams, an IAM user with MFA for a lone learner), never rootRoot has unlimited power and cannot be restricted
How does the CLI authenticate?SSO, or aws login, or CloudShell. Access keys only as a last resortTemporary credentials limit the damage of a leak
Free plan or Paid plan while learning?Free planIt cannot create a surprise bill
How many accounts?One for this course. Many in real companies (Chapter 8)Accounts are the strongest isolation boundary
Where do I run commands?CloudShell to start, your laptop CLI when you want your own toolsCloudShell needs no setup and no stored credentials
How do I find what to delete?A consistent tag (Lab=chNN) and templates for anything bigger than a few resourcesYou cannot delete what you cannot find
What is the first thing to create?A budget with alerts, then Cost ExplorerWarnings before spending, history from day one

Traps: Mistakes That Cost Marks and Money#

Access keys in code. Pasting an access key into a script and pushing it to a public Git repository is the classic way accounts get hijacked. Bots find such keys within minutes. Never put keys in code, files or chat. Use temporary credentials, and roles for programs running on AWS.

Confusing the account root user with an IAM user. "Root user" is the account owner identity from the sign-up email. An "IAM user" is something you create. A common exam question: "Which identity should be used for everyday tasks?" Answer: not the root user.

Thinking the budget protects you. It only warns, and the data is delayed. Read the email, act the same day, and delete resources.

Working in the wrong Region. A Mumbai bucket, a Virginia server and a Frankfurt database make a confusing lab. Set the Region once, check it every time.

Your account security checklist (print it): root MFA on, with a backup device. Root access keys: none. Alternate contacts set. Daily work with a non-root identity that has MFA. No long-lived access keys in files or code. Budget alert active. CloudTrail records are on by default for 90 days of management events (Chapter 36 extends this).

4.9 Hands-on Lab: Secure the Account, Set a Budget, Run Your First Commands#

Time: 45 minutes. Cost: about $0 (an empty S3 bucket for a few minutes). Region: Mumbai (ap-south-1). You need: an email address, a phone, and a card. Skip step 1 if your account already exists.

Step 1. Create the account#

Go to the AWS sign-up page and follow section 4.1. Choose the Free plan and Basic support.

Step 2. Lock the root user#

  1. Sign in as the root user. Open the account menu (top right) and choose Security credentials.
  2. Add MFA: choose a passkey or authenticator app. Add a second device as a backup.
  3. Check that Access keys shows none. Delete any that exist.
  4. Open Account, add alternate contacts (billing, operations, security), and set an account alias through IAM.
  5. Open Billing and Cost Management, then Billing preferences, and turn on IAM user and role access to billing information and Free Tier usage alerts.

Step 3. Create your daily admin identity#

  1. Open IAM, then Users, then Create user. Name it for yourself, for example maya-admin.
  2. Tick console access, set a password, and attach the managed policy AdministratorAccess (for this single learning account only).
  3. Sign out of root. Sign in again with the alias URL as maya-admin. Add MFA to this user too.
  4. From now on, use only this identity. Chapter 7 replaces it with IAM Identity Center.

Step 4. Create the budget#

Follow section 4.3: a monthly cost budget of $10 with your email, then add the 50 percent actual and 100 percent forecast alerts. Also enable Cost Explorer and Cost Anomaly Detection.

Step 5. Open CloudShell and ask "who am I?"#

Make sure the Region menu says Asia Pacific (Mumbai). Click the >_ icon and run:

aws sts get-caller-identity
aws configure list
aws ec2 describe-regions --query "Regions[].RegionName" --output text

Step 6. Install the CLI on your computer and sign in#

aws --version
aws login --profile stackcafe-learning     # sign in through the browser. No access key needed
aws sts get-caller-identity --profile stackcafe-learning

If aws login is not recognized, update the AWS CLI v2. If you work on a machine with no browser, add --remote to the login command.

Step 7. Create, tag, find and delete a bucket (the cleanup drill)#

ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
BUCKET=stackcafe-lab-ch04-$ACCOUNT

aws s3api create-bucket --bucket $BUCKET --region ap-south-1 \
  --create-bucket-configuration LocationConstraint=ap-south-1

aws s3api put-bucket-tagging --bucket $BUCKET \
  --tagging 'TagSet=[{Key=Lab,Value=ch04},{Key=Project,Value=stackcafe}]'

aws s3api get-bucket-tagging --bucket $BUCKET        # confirm the tags are there
aws s3 ls | grep stackcafe-lab                       # find it

aws s3 rb s3://$BUCKET                               # delete it (the bucket must be empty)
aws s3 ls | grep stackcafe-lab || echo "Clean: nothing left"

Step 8. Run the sweep#

Run the sweep script from section 4.8. If it prints nothing, you have no running servers anywhere.

What you should see

Step 5 prints your 12-digit account ID and an ARN ending in your identity (for example user/maya-admin or assumed-role/... in CloudShell). Step 6 prints the same account ID, with an ARN that reflects how you signed in. Step 7 shows the two tags, lists the bucket, then prints "Clean: nothing left". If bucket creation fails with BucketAlreadyExists, the name was taken: add a random number to it. If it fails with IllegalLocationConstraintException, you forgot the --create-bucket-configuration line.

In the Billing console, Budgets should show your monthly budget, and Free Tier should show your credit balance. Do not worry if cost graphs are empty, as data appears after a day.

Cleanup checklist: the lab bucket is already deleted in step 7. Keep the budget, the MFA devices and the admin user: you need them for the rest of the course. Nothing else was created.

Cheat Sheet#

TopicRemember
Root userMFA on (plus a backup), no access keys, almost never used. Use an admin identity for daily work
Free planUp to $200 credits, 6 months or until used. Cannot create a surprise bill. NAT gateways, load balancers, databases drain credits
BudgetAlerts only. Not a hard stop. Billing data is delayed. Create it first
CLI sign-inSSO, then aws login, then CloudShell. Access keys last
Who am I?aws sts get-caller-identity
Six waysConsole, CLI, CloudShell, SDK, infrastructure as code, raw API. All are API calls
TagsProject, Environment, Owner, CostCenter, Lab. Activate cost allocation tags in Billing
ARNarn:partition:service:region:account:resource
CleanupTag, delete in reverse order, sweep every Region, check Cost Explorer daily
DAY ONE      sign up > root MFA (x2) > alternate contacts > no root keys > admin identity > budget > Cost Explorer
DAILY        console to explore | CloudShell for commands | CLI with SSO or `aws login` | tag everything | clean up
CHECK        Region menu first | aws sts get-caller-identity | Cost Explorer | sweep script
FREE?        credits yes | always-free allowances yes | NAT gateway, ALB, EKS, RDS, public IPv4: NO
NEVER        root for daily work | access keys in code | trusting a budget to stop spending

Quick Recap#

  • An AWS account is the basic boundary for security and billing. The root user owns it and must be locked down with MFA (and a backup), have no access keys, and be used almost never.
  • Do daily work with a separate admin identity with MFA.
  • The Free plan gives up to $200 in credits for up to 6 months and cannot create a surprise bill. Some services (NAT gateways, load balancers, EKS, databases, public IPv4) use credits fast.
  • A budget sends alerts. It does not stop spending, and billing data is delayed.
  • CloudShell is a free, signed-in terminal. For your own computer, install CLI v2 and sign in with SSO or aws login, not long-lived keys.
  • aws sts get-caller-identity tells you who and where you are.
  • The console, CLI, SDK, IaC and raw requests are six doors to one API.
  • Tag and name everything. Delete the same day. Sweep every Region.
  • The 25-service map is your index for the rest of the course.

Practice Section A: Certification-Style Scenarios (10)#

Click Show answer to reveal each answer. Try before you open it. Aim for 9 or more.

Q1. A company has just created a new AWS account. What should be done first to protect the root user?

A. Create access keys for the root user
B. Enable multi-factor authentication (MFA) on the root user
C. Share the root password with the team
D. Use the root user for daily administration

Show answer

B. Enable MFA on root, never create root access keys, and use a separate identity for daily work.

Q2. Which identity should be used for everyday administrative tasks in an AWS account?

A. The root user
B. An IAM identity (or Identity Center user) with only the permissions it needs, protected by MFA
C. A shared account used by everyone
D. An anonymous user

Show answer

B. The root user is reserved for the few tasks that require it. Daily work uses a limited, MFA-protected identity.

Q3. A student wants to experiment with AWS without risking an unexpected bill. Which option fits best?

A. A Paid plan with no budget
B. The Free plan on a new account, which uses credits and cannot incur charges
C. Using the root user
D. Running everything in many Regions

Show answer

B. The Free plan on new accounts provides credits for up to 6 months and does not charge, ending when credits or time run out.

Q4. A team creates an AWS Budget with an email alert at 100 percent. The budget is reached on Friday night. What happens?

A. AWS automatically stops all resources
B. AWS closes the account
C. The team receives a notification, but resources keep running and spending continues
D. AWS refunds the overspend

Show answer

C. A budget alert is a notification. It does not stop resources unless you also configure a budget action, and even those depend on delayed billing data.

Q5. A developer needs to run AWS CLI commands from a laptop. Which approach is the most secure?

A. Create a long-lived access key for the root user
B. Sign in with IAM Identity Center (SSO) or aws login to get temporary credentials
C. Save an access key in the source code
D. Email credentials to the laptop

Show answer

B. Temporary credentials expire automatically, which limits the damage of a leak. Long-lived keys, and especially root keys, should be avoided.

Q6. Which AWS tool provides a browser-based terminal that is already authenticated and has the AWS CLI installed?

A. AWS CloudTrail
B. AWS CloudShell
C. AWS Config
D. AWS Artifact

Show answer

B. CloudShell opens from the console, uses your console credentials and includes the CLI and common tools.

Q7. Which feature lets a company see how much each project spends, after the right setup?

A. Resource tags activated as cost allocation tags
B. Larger instance sizes
C. Security groups
D. Availability Zones

Show answer

A. Tags such as Project and CostCenter, once activated for cost allocation, appear in Cost Explorer and billing reports.

Q8. What does the following identifier represent? arn:aws:ec2:ap-south-1:123456789012:instance/i-0abc123

A. An S3 bucket in any Region
B. An EC2 instance in the Mumbai Region of account 123456789012
C. An IAM user
D. A CloudFront distribution

Show answer

B. An ARN reads: partition, service (ec2), Region (ap-south-1), account ID, then resource type and ID.

Q9. Which statement about the AWS Management Console, CLI and SDKs is correct?

A. They use completely different back ends
B. They all ultimately call the same AWS APIs
C. Only the console can create resources
D. Only the SDK checks permissions

Show answer

B. Every tool sends signed API requests. IAM checks permissions the same way regardless of the tool.

Q10. A lab left a NAT gateway and a load balancer running over a weekend, although the instances were deleted. Why was the account still billed?

A. NAT gateways and load balancers are charged by the hour while they exist, even with no instances
B. Deleted instances keep charging
C. Budgets create charges
D. CloudShell charges per command

Show answer

A. Those resources have hourly charges independent of servers. That is why every lab ends with a cleanup checklist.

Practice Section B: Interview and Solution Design Questions (10)#

There is no single multiple-choice answer. Say your answer out loud first, then open the model answer. Interviewers care about clear reasoning and trade-offs.

I1. You have just been given a brand-new AWS account. What do you do in the first hour, and why?

Show model answer

I protect the root user first: strong unique password, MFA with a backup device, no access keys, alternate contacts set. Then I create a non-root admin identity with MFA (or set up IAM Identity Center) and stop using root. Next I turn on billing access for that identity, create a budget with alerts and enable Cost Explorer and anomaly detection, so spending is visible from day one. Then I choose a default Region and a tagging convention. The order matters: reduce the worst risk (account takeover), then the next risk (cost), then organize.

I2. Why should the root user not be used for daily tasks?

Show model answer

It has unrestricted power and cannot be limited by IAM policies, SCPs aside, so any mistake or compromise has the maximum blast radius. Its activity is harder to attribute to a person, and its credentials are the highest-value target for attackers. A limited identity with MFA gives the same convenience with a fraction of the risk. Root stays for the small set of tasks that require it, such as changing the account email or closing the account.

I3. A teammate pasted an AWS access key into a public GitHub repository. What do you do?

Show model answer

Act immediately: deactivate and then delete the key in IAM, so it stops working. Then review CloudTrail for what the key did, look for unexpected resources (especially large instances in unusual Regions), and delete them. Rotate any other secrets that were reachable. Remove the key from the repository, though history still contains it, so consider it burned. Prevent it next time: use temporary credentials and roles instead of keys, enable secret scanning and pre-commit checks, and apply least privilege so a leaked key cannot do much.

I4. Explain the difference between a budget alert and a spending limit. How would you protect a learning account?

Show model answer

A budget alert notifies you when actual or forecast spend crosses a threshold. It does not stop resources, and billing data is delayed by hours. AWS has no simple global hard cap for a normal paid account. For a learning account I would use the Free plan, where credits are the limit, add a small budget with several thresholds, keep labs tiny, tag them, and clean up daily. For a company I would add budget actions or policies that restrict creating costly resources, plus anomaly detection.

I5. Why do professionals prefer SSO or aws login to access keys for the CLI?

Show model answer

Both give temporary credentials that expire and refresh automatically, so a leaked laptop or log file exposes access for hours rather than forever. Access keys are long-lived secrets that get copied into files, scripts and repositories, and they rarely get rotated. SSO adds central control: a user can be disabled in one place, with MFA and consistent permissions across many accounts. Keys are only acceptable for tools that cannot use anything else, and then with minimal permissions and rotation.

I6. The console, CLI, SDK and CloudFormation all create an S3 bucket. What is the same underneath, and why does it matter?

Show model answer

Each one sends a signed API request to the S3 service, and IAM evaluates the same permissions. It matters because security and auditing are applied at the API level: a policy that denies bucket creation blocks all four, and CloudTrail records the call regardless of how it was made. It also tells me which tool to use: the console to learn, the CLI for quick tasks, the SDK inside applications, and infrastructure as code for repeatable, reviewable environments.

I7. Design a tagging strategy for a company with five teams and three environments.

Show model answer

A small mandatory set: Project or Application, Environment (dev, test, prod), Owner, and CostCenter, with fixed allowed values and consistent case. I would activate them as cost allocation tags, enforce them with tag policies or service control policies so resources cannot be created without them, and apply tags through infrastructure as code so they are never forgotten. Reports by tag then give showback per team and environment, and automation can use tags to find and delete expired resources.

I8. Your bill doubled this month. How do you investigate?

Show model answer

I open Cost Explorer, group by service, then by usage type, Region and tag, and compare with last month to find the line that grew. I check Cost Anomaly Detection for flagged events. Then I look at the cause: often forgotten resources (NAT gateways, load balancers, unattached volumes), data transfer, or a new workload. I use tags to find the owner, fix the cause, and add a budget or alert so the next jump is caught earlier. I also look at CloudTrail if the growth looks like unauthorized use.

I9. What is the difference between a resource's Region, its name, its tags and its ARN, and how do you use each to find what you created?

Show model answer

They solve different problems. The Region and AZ say where a resource lives, which you must know to see it at all in the console. A name is a human label, and not always unique. Tags are searchable metadata for grouping and cost. The ARN is the unique, complete identifier that includes partition, service, Region, account and resource, used in policies and automation. To find everything for one lab I search by a tag across Regions, and use ARNs when writing permissions.

I10. A new colleague asks, "Why not just give everyone the root login to avoid permission problems?" Respond.

Show model answer

Because it removes accountability and maximizes risk. With one shared login nobody can tell who did what, MFA cannot belong to a person, and one phished password gives an attacker the whole account including the ability to remove our backups and close the account. Permission problems are solved by giving each person their own identity and the specific permissions they need, ideally through SSO and groups, and by using Access Analyzer and the policy simulator to find the missing permission. It takes minutes to fix a permission, but a root compromise cannot be undone.

Next up: Chapter 5. AWS Pricing: Become Your Own AWS Calculator (the five-step estimation method, meters and units, Savings Plans versus Spot with break-even math, hidden costs, and worked bills for a serverless and a three-tier StackCafe).