Lesson 8 of 30Identity and security
Multiple Accounts, Organizations and SSO
Why companies run dozens of AWS accounts, how Organizations, SCPs and Identity Center tie them together, and how you sign in to them every day.
On your first day at most companies you will not get "the AWS account". You will get a portal link with fifteen tiles: payments-dev, payments-prod, shared-network, log-archive, sandbox-yourname. Each tile is a separate AWS account, and each lets you pick a role like ReadOnly or Developer. This lesson explains why the setup looks like that, which guardrails sit above every account, and how to work with it from your terminal without leaking credentials or deploying to the wrong place. It builds on the policy evaluation flow from IAM Policies in Depth, where SCPs and RCPs first appeared.
Why one account is not enough
An AWS account is the strongest isolation boundary AWS offers. IAM policies, VPCs and tags can separate things inside an account, but every one of them can be misconfigured. Two accounts share nothing by default: not IAM, not networks, not quotas, not the bill.
That gives you:
- Blast radius. A leaked developer key in
payments-devcannot touchpayments-prod. A runaway script that deletes every bucket deletes only that account's buckets. - Billing separation. Each account's spend is visible on its own, so "what does the search team cost?" is a filter, not a tagging project.
- Separate quotas. Lambda concurrency, API rate limits and many service quotas are per account per Region. A load test in staging cannot throttle production.
- Simpler IAM. Inside
payments-dev, developers can have broad permissions because there is nothing else in there to protect. - Clean ownership. Close an account and everything in it is gone. No hunting for forgotten resources.
The cost is overhead: more places to configure, cross-account access to design, and a need for central tooling. That is what AWS Organizations, Control Tower and IAM Identity Center are for.
A typical layout
Most companies converge on a structure close to AWS's own multi-account guidance. Step through it.
The management account creates the organization, pays the bill and runs Organizations. Keep workloads out of it: SCPs do not apply to it, so anything there is unguarded.
An organizational unit (OU) is a folder of accounts. You attach policies to OUs rather than accounts, so a new account dropped into Prod inherits production guardrails on day one.
Organizations: SCPs, RCPs and friends
AWS Organizations links the accounts. It gives you consolidated billing, the OU tree, and policies attached to the tree. The two you will meet most are the ones from the evaluation flow:
- SCPs cap what principals in member accounts can do, including each member account's root user.
- RCPs cap what can be done to resources in member accounts, by anyone, including principals outside the organization.
SCP inheritance follows two rules. A Deny attached anywhere on the path from Root to the account applies. And every level on that path must have an Allow for the action, which is why the default FullAWSAccess policy sits on every node. Remove it from one OU without a replacement and everything below it stops working.
Most teams write deny-list SCPs: keep FullAWSAccess, add targeted Denies. The classic three:
{
"Version": "2012-10-17",
"Statement": [
{ "Sid": "StayInOrg", "Effect": "Deny",
"Action": "organizations:LeaveOrganization", "Resource": "*" },
{ "Sid": "KeepAuditOn", "Effect": "Deny",
"Action": ["cloudtrail:StopLogging", "cloudtrail:DeleteTrail", "cloudtrail:UpdateTrail"],
"Resource": "*" },
{ "Sid": "ApprovedRegionsOnly", "Effect": "Deny",
"NotAction": ["iam:*", "organizations:*", "sts:*", "route53:*", "cloudfront:*",
"support:*", "budgets:*", "health:*"],
"Resource": "*",
"Condition": {
"StringNotEquals": { "aws:RequestedRegion": ["eu-west-1", "eu-central-1"] },
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/platform-break-glass" }
}
}
]
}The region lock uses NotAction in a Deny, the safe place for it, to exempt global services whose calls are served from us-east-1. The exemption list here is shortened. Start from the example in the Organizations docs, because missing a global service breaks things in confusing ways. The ArnNotLike condition lets one break-glass role act everywhere.
RCPs are how you build a data perimeter: "our buckets, keys and secrets can only be reached by our own principals". An RCP on the Workloads OU can deny s3:* when aws:PrincipalOrgID is not your org ID, unless aws:PrincipalIsAWSService is true. One policy then protects every bucket, even one with a careless bucket policy.
Organizations has other policy types you should recognize: tag policies (standardize tag keys and values), backup policies, and declarative policies that pin service configuration such as blocking public AMI sharing. Many security services also support a delegated administrator: you run GuardDuty or Security Hub for the whole org from security-tooling instead of the management account, so fewer people need management account access.
Here is SCP inheritance as code. Each node lists its attached SCPs; a request is checked level by level from Root down.
Press Run (⌘ Enter) to see what happens.The sandbox shows the other style, an allow-list SCP: instead of FullAWSAccess, the Sandbox OU allows only four services, so DynamoDB is denied there even though nothing says "Deny". Note the last word of every Allow: an SCP passing only means IAM gets to decide.
A teammate tidies up the Workloads OU by detaching FullAWSAccess, leaving only EU_ONLY. Add these lines to the end of the block. What does it print?
ORG["Workloads"] = ("Root", [EU_ONLY])
print(decide("payments-prod", "dynamodb:PutItem", "eu-west-1"))Control Tower and landing zones
Building all of the above by hand takes weeks. AWS Control Tower sets up a landing zone: the organization, Security OU, log archive and audit accounts, an org-wide CloudTrail, IAM Identity Center, and a library of controls. Controls come in three kinds: preventive (implemented as SCPs or RCPs), detective (AWS Config rules that flag drift) and proactive (CloudFormation hooks that block non-compliant resources before they are created).
Account Factory then vends new accounts into the right OU with a baseline applied. Teams that manage everything in Terraform often use Account Factory for Terraform (AFT), or skip Control Tower and manage Organizations directly with Terraform modules. At work you will rarely build this yourself. You should know which approach your company uses, because it decides how you request an account and where guardrails are defined.
Match each need to the account or feature that handles it.
IAM Identity Center for people
Nobody should have an IAM user in each account. IAM Identity Center (formerly AWS SSO) is the one front door for humans.
- Identity source. Users and groups come from Identity Center's own directory or, far more often at companies, from an external identity provider such as Microsoft Entra ID, Okta or Google Workspace, synced with SCIM. When someone leaves and HR disables them in the IdP, their AWS access ends too.
- Permission sets. A permission set is a template: managed policies, an inline policy, an optional permissions boundary and a session duration (1 to 12 hours).
- Assignments. You assign a group plus a permission set to an account. Identity Center then creates a role in that account, named like
AWSReservedSSO_Developer_1a2b3c4d. People never see keys: signing in assumes that role and returns temporary credentials.
A common design: ReadOnly everywhere for engineers, Developer in non-prod, and production write access only through a separate ProdDeploy set that few people hold, or through CI only.
Your terminal: profiles and aws sso login
From the CLI you configure Identity Center once and sign in per day. Use the sso-session style. It refreshes tokens automatically and shares one login across many profiles:
[sso-session acme]
sso_start_url = https://acme.awsapps.com/start
sso_region = eu-west-1
sso_registration_scopes = sso:account:access
[profile payments-dev]
sso_session = acme
sso_account_id = 111111111111
sso_role_name = Developer
region = eu-west-1
[profile payments-prod-ro]
sso_session = acme
sso_account_id = 222222222222
sso_role_name = ReadOnly
region = eu-west-1aws configure ssoaws sso login --sso-session acmeaws sts get-caller-identity --profile payments-devexport AWS_PROFILE=payments-prod-roaws s3 lsaws configure sso writes the file for you. aws sso login opens a browser (recent CLI versions use the PKCE flow by default; --use-device-code gives the older code-on-another-device flow for headless machines) and caches a token under ~/.aws/sso/cache. After that, every profile on the same session gets fresh role credentials on demand until the session expires.
The CLI starts an OAuth flow and opens your browser.
Tools such as Granted and aws-vault wrap this flow to open several accounts in separate browser containers or assume roles quickly. They are popular at companies with many accounts, but the underlying mechanism is the same.
The credential provider chain and the stale-key bug
The CLI and SDKs look for credentials in a fixed order and stop at the first hit. Simplified for the CLI and boto3:
- Explicit options:
--profileon the CLI, orprofile_nameinboto3.Session(...) - Environment variables:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN - The selected profile in
~/.aws/configand~/.aws/credentials: assume-role settings, web identity, Identity Center, static keys,credential_process - Container credentials (ECS task role, EKS Pod Identity)
- EC2 instance profile from the instance metadata service
Here is the bug you will hit. Last week you pasted temporary keys into your shell to debug something, and the variables are still set in that terminal. Today you run export AWS_PROFILE=payments-dev and deploy. AWS_PROFILE only selects a profile. It does not outrank the key variables, so the deploy runs as last week's identity, in whatever account that was. If those keys pointed at production, you just deployed dev code to prod. The --profile flag does win over environment keys, which is why the same command can behave differently with the flag and with the variable.
Always check who you are before anything destructive:
aws sts get-caller-identityaws configure listenv | grep AWS_unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKENaws configure list shows where each value came from: env, sso, shared-credentials-file and so on. Many engineers put the current profile and account in their shell prompt for exactly this reason.
AWS_PROFILE=payments-dev is exported, but aws sts get-caller-identity returns an ARN in the production account. What is the most likely cause?Root users and break-glass access
Every account has a root user, so 40 accounts means 40 root users to protect. Since late 2024, centralized root access management lets the management account (or a delegated admin) remove root credentials from member accounts entirely: no password, no keys, no MFA device to look after. New accounts created in the organization can start without root credentials. The few tasks that truly need root, such as unlocking an S3 bucket policy that denies everyone, are done as short privileged sessions through sts:AssumeRoot, from the management account.
The management account's own root user still exists. Protect it with phishing-resistant MFA (a hardware key or passkey), no access keys, and an alert on every sign-in through an EventBridge rule on root ConsoleLogin events.
Break-glass access is your plan for when Identity Center or your IdP is down during an incident. Typically it is one or two tightly guarded roles or IAM users, with credentials in a physical safe or a separate vault, MFA required, excluded from SCP restrictions through a condition like the platform-break-glass exemption above, and an alarm that pages security whenever they are used. Test it twice a year. A break-glass path nobody has tried will not work at 3 a.m.
Organization CloudTrail and the log archive
An organization trail, created in the management account or a delegated admin account, records API activity in every account and Region into one S3 bucket in log-archive. Member accounts can see the trail but cannot change or delete it, and the SCP above stops them from stopping it. Lock the bucket down: a bucket policy that only lets CloudTrail write, S3 Object Lock or at least versioning with MFA delete, and a lifecycle rule to cheaper storage for old logs. When security asks "what did this leaked key do across all our accounts?", this bucket (queried with Athena or CloudTrail Lake) is the answer.
- AWS Organizations
- The service that groups accounts into OUs under one management account, with consolidated billing and org-wide policies.
- OU
- Organizational unit. A folder of accounts that policies such as SCPs are attached to and inherited through.
- management account
- The account that owns the organization. SCPs and RCPs do not apply to it, so keep workloads out of it.
- landing zone
- A pre-built multi-account baseline: OUs, log archive, audit, guardrails and SSO. Control Tower creates one.
- permission set
- An Identity Center template of policies and session length, deployed as a role into each assigned account.
- credential provider chain
- The fixed order in which the CLI and SDKs look for credentials, stopping at the first source found.
- break-glass access
- Emergency credentials kept offline and alarmed, for when normal sign-in is unavailable.