Lesson 2 of 8 in Cloud fundamentals with AWS

Accounts and billing safety before you build

Core12 minWritten for AWS CLI v2 (preinstalled in CloudShell)

An AWS account is the container that owns your resources and your bill. The root user is the login that created the account and can do anything, so you protect it with multi-factor authentication (MFA) and use it as little as possible.

Draft. This lesson is written and waiting for a person to run every command and review it. It is safe to learn from, but check the official documentation for anything you depend on.

Read these first: What the cloud is: regions, zones and who secures what

The problem this solves

Cloud tutorials usually start with 'create a resource' and end with 'enjoy your app'. They skip the part where you remember to delete it. Billing is metered by the hour or by the gigabyte, so a forgotten resource quietly costs money while you sleep.

Your account also needs protecting. The root user has unlimited power, including closing the account. If someone steals that password and there is no second factor, they own everything and the bill.

So you do three things before building anything: protect the root login, set up alerts so spending cannot go unnoticed, and make a separate everyday login that is not root.

How it works

How a budget alert reaches you
How a budget alert reaches youYour resources generate usage, billing data records it, a budget compares it with your limit and emails you, and then you decide what to delete.1 usage ismetered2 compared tolimit3 alert email4 you delete itYour resourcesVMs, disks, storageBilling datarefreshed several times a dayBudgetcompares to your limitYouget an email
  • Runs code
  • Control
  • People and clients

Your resources generate usage, billing data records it, a budget compares it with your limit and emails you, and then you decide what to delete.

  1. Your resources to Billing data: 1 usage is metered
  2. Billing data to Budget: 2 compared to limit
  3. Budget to You: 3 alert email
  4. You to Your resources: 4 you delete it
Keep root locked away and sign in as a daily user
Keep root locked away and sign in as a daily userYou sign in every day as a normal user protected by an MFA code, and you open the root user only for the rare tasks that need it.1 sign in2 asks for acode3 signed inrarelyYouRoot useremergency onlyDaily userlimited permissionsMFA codesecond factorConsoleyour account
  • People and clients
  • Security
  • Control

You sign in every day as a normal user protected by an MFA code, and you open the root user only for the rare tasks that need it.

  1. You to Daily user: 1 sign in
  2. Daily user to MFA code: 2 asks for a code
  3. MFA code to Console: 3 signed in
  4. You to Root user: rarely

A budget is a rule you write: 'tell me when spending passes this amount'. AWS compares your recorded usage to the rule and emails the address you gave. Billing data is not live. It is refreshed several times a day, so an alert can arrive hours after the spending started. A budget warns you. It does not stop or delete anything.

AWS also has a free plan for new accounts. Accounts created on or after 15 July 2025 can choose a free plan that gives credits to spend and lasts up to 6 months or until the credits run out, whichever comes first. AWS says some services that would use up the credit at once are not available on it. Check the current Free Tier page when you sign up, because plans change.

The root user is the email address you signed up with. Turn on MFA for it, never create access keys for it, and then stop using it. For daily work, make a separate user with its own MFA, which the next concept covers. Azure and Google Cloud have the same idea: both offer budgets with email alerts at the billing level, and both want you to keep the original owner login out of daily use.

Try it yourself

These steps use the AWS web console. They create no billable resources. You need an email address and a payment card, which AWS asks for at sign-up.

  1. 1
    Create the account and pick the free plan

    Go to the AWS sign-up page and create an account with an email you control. When asked, choose the free plan. Choose the Basic support plan, which costs nothing. Write down which Region you will use for all labs and stay in it.

  2. 2
    Protect the root user with MFA

    Sign in as the root user. Open the menu with your account name in the top right, choose Security credentials, and under Multi-factor authentication choose Assign MFA device. A passkey or an authenticator app both work. Do not create root access keys. Then sign out of root.

  3. 3
    Create a zero-spend budget

    Open Billing and Cost Management, then Budgets, then Create budget. Choose the simplified template called Zero spend budget, enter your email address, and create it. It emails you when you start incurring cost. If you also want a ceiling you pick yourself, create a second budget from the Monthly cost budget template with a small amount.

  4. 4
    Turn on free tier alerts

    Open Billing preferences and find the alert preferences. Turn on the free tier usage alerts and enter your email address. Menu labels move around, so search the console for 'Billing preferences' if you cannot find it.

  5. 5
    Confirm the budget exists from the command line
    ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
    aws budgets describe-budgets --account-id "$ACCOUNT" --query "Budgets[].[BudgetName,BudgetLimit.Amount]" --output table

    Run this in AWS CloudShell, the terminal icon in the console's top bar. It is already signed in as you, needs no access keys and is free to use. The account ID stays in a shell variable and is never printed. Your budget's name should appear in the table.

What breaks, and where to look

  • You sign in as a normal user and a billing page says: You don't have permission to access billing information for this account.

    WHY IT HAPPENS
    By default only the root user can see billing pages. Root has to switch on access for IAM users and roles, and the user also needs permissions that allow billing.
    CHECK FIRST
    Sign in as root, open Account settings, and look for 'IAM user and role access to Billing information'. Activate it, then check the user's attached policies in IAM.
  • Spending went up but no alert email arrived.

    WHY IT HAPPENS
    Billing data refreshes only a few times a day, the email may be in spam, or the budget points at an address you mistyped. Also, a budget never stops spending, it only informs.
    CHECK FIRST
    Open Budgets and read the budget's current amount and notification recipients. Then open the Bills page, sorted by service, to see what is costing money.
  • You cannot sign in to root because the phone with your authenticator app is gone.

    WHY IT HAPPENS
    MFA protects the account, but it also locks you out if the only device is lost.
    CHECK FIRST
    Use the sign-in page's option for a problem with your MFA device and follow the recovery steps. Prevent this by registering a second MFA device for the root user when you set it up.

When not to use this

  • A budget only warns you. On a paid plan nothing stops spending automatically, so deleting what you create is still your job.
  • Teams with many accounts manage billing and access centrally with AWS Organizations. One personal learning account does not need that yet.

Check yourself

Why should you stop using the root user for daily work?

It has unlimited power, so a stolen or mistyped root login can do the most damage. A limited daily user with MFA keeps the risk small.

Does a budget stop resources when you pass the limit?

No. A budget sends an alert. You have to delete resources yourself.

Why can a budget alert arrive late?

Billing data is refreshed several times a day, not instantly, so the alert follows the spending by hours.

Lesson 56 of 92 in the DevOps path

Search

Search cheat sheets and projects