Sub topic 2
Accounts, Regions, and identities
This chapter assumes you know what AWS is, can run shell commands, and have an AWS account you can sign in to. It explains three ideas that every later tool depends on: which account you are in, which Region you are targeting, and who you are signed in as.
Accounts
An AWS account is the container for your resources and the boundary for billing and access. Each account has a 12-digit account ID, such as 111122223333. Resources in one account are not visible to another account unless you share them on purpose.
Many organizations use several accounts, for example one for development and one for production. You will often switch between them, so always check which one is active before you change anything.
Regions
A Region is a separate geographic area where AWS runs its data centers. Each Region has a code, such as us-east-1 (N. Virginia) or eu-west-1 (Ireland).
Most services are regional. An EC2 instance you create in eu-west-1 does not exist in us-east-1. If a resource seems to have vanished, you are often looking at the wrong Region. A few services, such as IAM, are global and do not depend on the Region you choose.
Some newer Regions are opt-in, which means they are disabled until you enable them for your account.
Identities
An identity is the "who" behind each request. AWS checks the identity's permissions before it allows an action.
| Identity | What it is | Typical use |
|---|---|---|
| Root user | The original owner of the account, with unrestricted access | Rare account-level tasks only |
| IAM user | A person or application defined inside one account, often with long-lived access keys | Older setups and some legacy tools |
| IAM Identity Center user | A person signed in through a central portal, with access to one or more accounts | Day-to-day work by people |
| IAM role | An identity you assume temporarily, which issues short-lived credentials | Applications, services, and cross-account access |
How the pieces fit together
You sign in as an identity, which belongs to or can reach an account. You then choose a Region for each regional request.
Checking who you are
The most reliable check is to ask AWS which identity your credentials resolve to:
aws sts get-caller-identityThe response lists three fields:
{
"UserId": "AROAEXAMPLEID:alice",
"Account": "111122223333",
"Arn": "arn:aws:sts::111122223333:assumed-role/ReadOnly/alice"
}Account tells you which account is active. Arn shows the identity type, here an assumed role. This command works with any valid credentials and needs no special permission. The Console shows the same facts in the account menu at the top right, and you will use it in the next chapters.
To see which Region the CLI will use by default, run:
aws configure get regionIf this prints nothing, no default Region is set, and many commands will fail until you pass --region or configure one.
Common mistakes
- Looking for a resource in the wrong Region.
- Running a command against the wrong account because an old profile or environment variable took priority.
- Assuming a global service such as IAM follows the Region selector.
Exercise
You created an S3 bucket's companion EC2 instance in eu-west-1, but aws ec2 describe-instances returns nothing. Your credentials are valid. What are two things to check, and which command shows the account you are using?
Show answer
Check which Region the command targets (the default Region or --region), because EC2 instances are regional, and check that you are in the intended account. Run aws sts get-caller-identity to see the active account and identity. Then repeat the command with --region eu-west-1.