Accounts, billing alerts and the CLI
Before building anything, set up your account safely: protect the all-powerful root login, create a billing alert so a mistake can't run up a surprise bill, and install the command-line tool, which you'll use for the rest of this course. These steps take 20 minutes and prevent the two classic beginner disasters: a hacked account and a huge invoice.
1. Create the account
Each provider gives new accounts free credits or a free tier:
| Provider | Sign up | Free offer (check the current terms) |
|---|---|---|
| AWS | aws.amazon.com/free | Free tier plus credits for new accounts; some services always free in small amounts |
| Google Cloud | cloud.google.com/free | Credits for 90 days, plus an always-free tier |
| Azure | azure.microsoft.com/free | Credits for 30 days, plus 12 months of popular services and always-free services |
All three ask for a payment card to verify your identity. With the alerts below, you'll know long before you spend anything.
2. Lock down the root user
The email address you signed up with is the root user (AWS) or the owner: it can do absolutely anything, including closing the account. Protect it:
- Turn on multi-factor authentication (MFA): an authenticator app or, better, a passkey/hardware key.
- Don't use it day to day. Create a separate administrator identity for yourself (an IAM Identity Center user on AWS; on Google Cloud and Azure your normal account with the right roles).
- Never create access keys for the root user.
3. Set a billing alert
Do this before anything else. On AWS, create a budget that emails you when actual or forecast spending passes a limit:
cat > budget.json <<'EOF'
{
"BudgetName": "monthly-limit",
"BudgetLimit": { "Amount": "10", "Unit": "USD" },
"TimeUnit": "MONTHLY",
"BudgetType": "COST"
}
EOF
cat > alerts.json <<'EOF'
[
{
"Notification": { "NotificationType": "ACTUAL", "ComparisonOperator": "GREATER_THAN", "Threshold": 80, "ThresholdType": "PERCENTAGE" },
"Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "you@example.com" }]
},
{
"Notification": { "NotificationType": "FORECASTED", "ComparisonOperator": "GREATER_THAN", "Threshold": 100, "ThresholdType": "PERCENTAGE" },
"Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "you@example.com" }]
}
]
EOF
account=$(aws sts get-caller-identity --query Account --output text)
aws budgets create-budget --account-id "$account" --budget file://budget.json --notifications-with-subscribers file://alerts.json
aws budgets describe-budgets --account-id "$account" --query "Budgets[].[BudgetName, BudgetLimit.Amount, BudgetLimit.Unit]" --output textmonthly-limit 10 USD
You get an email at 80% of $10 actually spent, and another when AWS forecasts you'll pass $10 this month, which catches a forgotten server early. The same takes a few clicks in the console (Billing → Budgets). Google Cloud has Budgets & alerts under Billing, and Azure has Cost Management → Budgets.
⚠️ Budgets alert, they don't stop spending. Always delete what you're done with. Each lesson in this course ends with a clean-up step.
4. Install the CLIs
| Tool | Install |
|---|---|
| AWS CLI v2 | macOS: brew install awscli; Windows: the MSI installer; Linux: the zip from aws.amazon.com/cli |
Google Cloud CLI (gcloud) |
cloud.google.com/sdk/docs/install, or brew install --cask google-cloud-sdk |
Azure CLI (az) |
brew install azure-cli; Windows: winget install Microsoft.AzureCLI; Linux: Microsoft's script |
All three are also available, already logged in, in a browser terminal inside the web console: AWS CloudShell, Google Cloud Shell and Azure Cloud Shell. That's the quickest way to start.
aws --version | cut -d' ' -f1aws-cli/2.42.1
5. Sign in from the CLI
Avoid long-lived access keys on your laptop where you can. Each CLI can sign in through the browser and get temporary credentials:
# AWS, with IAM Identity Center (recommended) — opens the browser
aws configure sso
aws sso login --profile dev
# Google Cloud
gcloud auth login
gcloud config set project my-project-id
# Azure
az login
az account set --subscription "My Subscription"Whichever way you signed in, the first command to run is always "who am I?":
aws sts get-caller-identity{
"UserId": "AKIAIOSFODNN7EXAMPLE",
"Account": "123456789012",
"Arn": "arn:aws:sts::123456789012:user/moto"
}Example output from gcloud and az:
$ gcloud config list --format="value(core.account, core.project)"
asha@example.com learn-cloud-2026
$ az account show --query "{user: user.name, subscription: name}" -o table
User Subscription
----------------- ---------------
asha@example.com Azure for StudentsProfiles and regions
Most people work with several accounts (personal, work, development, production). The AWS CLI keeps them as profiles in ~/.aws/config:
[profile dev]
sso_session = my-sso
sso_account_id = 111111111111
sso_role_name = AdministratorAccess
region = ap-south-1
[profile prod]
sso_session = my-sso
sso_account_id = 222222222222
sso_role_name = ReadOnlyAccess
region = ap-south-1aws s3 ls --profile prod # one command
export AWS_PROFILE=dev # every command in this terminalEvery command also runs in a region. aws configure list shows which one, and where the setting came from (here an environment variable; usually your config file). Override it per command with --region:
aws configure list | grep -E 'region|Name'
aws ec2 describe-availability-zones --region eu-west-2 --query "AvailabilityZones[].ZoneName" --output textregion : ap-south-1 : env : ['AWS_REGION', 'AWS_DEFAULT_REGION'] eu-west-2a eu-west-2b eu-west-2c
Output formats and queries
The AWS CLI prints JSON by default. --output changes the format and --query (using the JMESPath language) picks out what you need, without extra tools:
aws ec2 describe-regions --query "Regions[?starts_with(RegionName, 'ap-')].RegionName" --output text | tr '\t' '\n' | sort | head -5
echo "---"
aws ec2 describe-availability-zones --region ap-south-1 --query "AvailabilityZones[].{Zone: ZoneName, State: State}" --output tableap-east-1 ap-east-2 ap-northeast-1 ap-northeast-2 ap-northeast-3 --- ------------------------------ | DescribeAvailabilityZones | +------------+---------------+ | State | Zone | +------------+---------------+ | available | ap-south-1a | | available | ap-south-1b | | available | ap-south-1c | +------------+---------------+
| Option | Gives |
|---|---|
--output json |
Full JSON (default), great with jq |
--output table |
Readable tables |
--output text |
Tab-separated values, ideal for shell scripts |
--query "…" |
Select and reshape the result |
gcloud uses --format (e.g. --format="table(name, zone)"), and az uses --query (also JMESPath) and -o table.
Practice
- Create a free account on one provider and turn on MFA for the root/owner login.
- Create a monthly budget of $5 with an email alert.
- Install the CLI (or open the provider's cloud shell) and run the "who am I?" command.
- List the availability zones of the region closest to you as a table.
1.What should you do with the AWS root user?
2.What does an AWS budget do when you pass the limit?
3.Which command tells you which AWS identity and account the CLI is using?
4.Which AWS CLI option selects just part of the response?