INF-10Recommended
Give each environment its own account
Run production in its own cloud account, project or subscription. Development, staging and previews each live in another one.
How to do it
An account is the strongest wall a cloud offers. Keys, limits, bills and mistakes stay inside it. Group the accounts under one organization, such as AWS Organizations, a Google Cloud organization or Azure management groups. Give staging and CI for staging no role they can take in production. Connect production networks to others only where one named service needs it. On a small host without accounts, use a separate project and API token per environment. Payment providers split the same way, as Keep test and live modes apart says.
Examples
Shell example
# Run with the staging deploy role. Expect AccessDenied.
aws sts assume-role --role-arn arn:aws:iam::111122223333:role/deploy-production --role-session-name check
How to check
The production account holds no resource tagged with another environment. The staging deploy role tries to assume the production deploy role and gets AccessDenied.
Sources
- AWS Well-Architected SEC01-BP01 Separate workloads using accounts
- AWS Benefits of using multiple accounts
Related rules
- INF-5 Split state by environment and layer in Infrastructure and environments
- PAY-5 Keep test and live modes apart in Payments and billing
- INF-64 Keep production data and secrets out of previews in Infrastructure and environments
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/infrastructure/environments/account-per-environment">Agent Wranglers infrastructure and environments playbook</a>. In code you write, add a comment next to it with the same link.