In the last post I set up a budget alert. The next step before building anything with AWS AI services is somewhere safe to build it. I want a separate account for experiments, so a mistake there cannot touch anything I care about, and I want to sign in without long-lived access keys sitting on my Mac.
What We Are Building
- A sandbox account created under AWS Organizations
- IAM Identity Center with one user and one permission set
- A CLI profile that signs in with
aws sso loginand gets temporary credentials
Before We Start
You need an existing AWS account to act as the management account, and a spare email address for the sandbox account. Each AWS account needs a unique root email. If your provider supports plus addressing, you+sandbox@example.com works.
Keep the management account for administration only. Do not build workloads in it.
Step 1: Create the Organization and the Sandbox Account
Console: open AWS Organizations, choose Create an organization, then Add an AWS account, Create an AWS account. Give it a name such as sandbox and the spare email address.
CLI:
aws organizations create-organization --feature-set ALL
aws organizations create-account \
--account-name sandbox \
--email you+sandbox@example.comAccount creation is asynchronous. Check progress with:
aws organizations list-accounts --query "Accounts[].[Name,Id,Status]" --output tableStep 2: Turn On IAM Identity Center
Do this in the management account, and check the Region selector in the top right first. Whichever Region is selected when you choose Enable becomes the primary Region of your instance, and it cannot be changed afterwards. Moving later means deleting the instance and starting again.
- Open IAM Identity Center in the management account, with your chosen Region selected
- Choose Enable (the organization from Step 1 must already exist)
- On the next page you choose an instance configuration. In Regions that support multi-Region, there are three options:
| Option | What you get | Cost note |
|---|---|---|
| Single-Region instance | Instance in the current Region only. Data encrypted with an AWS owned key. You can add Regions later from Settings. | No extra charge |
| Multi-Region instance | Instance in the current Region, replicated to one additional Region for resilient access. Creates a customer managed multi-Region KMS key for you. | AWS KMS charges apply |
| Custom instance | You pick the encryption key (AWS owned, a new customer managed key, or an existing one), and which additional Regions to add. A customer managed key is required to add Regions. | KMS charges if you use a customer managed key |
For a personal sandbox I choose Single-Region instance. Multi-Region replication is there so your team can still sign in to AWS if Identity Center has an outage in its primary Region, which is not a concern for one person with one sandbox. It also adds a KMS key to look after. Permission sets are enabled by default in all three options and cannot be turned off once enabled, which is what we want here.
- Under Users, create a user for yourself and set up MFA for it
Step 3: Give Yourself Access to the Sandbox
- Under Permission sets, create one. I start with the AWS managed
PowerUserAccesspolicy, which allows everything except IAM and Organizations management - Under AWS accounts, select
sandbox, choose Assign users or groups, pick your user and the permission set
I use PowerUserAccess rather than administrator access because most builds do not need to create IAM users. When a build does need IAM (roles for Lambda, for example), I will widen it on purpose and say so in that post.
Step 4: Sign In from the CLI
First, find the start URL. In the management account, open IAM Identity Center and choose Dashboard in the left-hand navigation. Look for the Settings summary box on the right of the page. The value you want is labelled AWS access portal URL. It looks like https://d-xxxxxxxxxx.awsapps.com/start, or https://your-subdomain.awsapps.com/start if you have customised it. Copy that whole URL, including /start.
Do not use the Issuer URL shown just below it in the same box. That one is for connecting external applications and will not work here.
Then run:
aws configure ssoIt asks for the following:
| Prompt | What to enter |
|---|---|
| SSO session name | Any name, for example renegade |
| SSO start URL | The AWS access portal URL you just copied |
| SSO region | The primary Region you enabled Identity Center in (Step 2). This is not necessarily where you will build things |
| SSO registration scopes | Press Enter to accept the default (sso:account:access) |
A browser window opens so you can sign in as the Identity Center user from Step 2 and approve the request. Back in the terminal it lists the accounts you can access: pick sandbox and your permission set. It then asks for a default Region (where you want to build, such as eu-west-2), an output format, and a profile name. I use sandbox. Then:
aws sso login --profile sandbox
aws sts get-caller-identity --profile sandboxThe account number in the output should be the sandbox account’s, not the management account’s. The credentials expire after a few hours and nothing secret is written to ~/.aws/credentials. Set the profile for a shell session with export AWS_PROFILE=sandbox.
Step 5: Repeat the Budget in the Sandbox
Budgets are per account unless you build them at the organization level. Deploy the CloudFormation template from the last post into the sandbox:
aws cloudformation deploy \
--profile sandbox \
--region eu-west-2 \
--template-file budget.yaml \
--stack-name monthly-budget \
--parameter-overrides BudgetAmount=10 AlertEmail=you@example.comWhat It Costs
AWS Organizations and IAM Identity Center have no charge of their own. An empty account costs nothing. Check current pricing before relying on this.
Cleaning Up
I keep all of this. If you want to remove the sandbox, sign in to it as the root user and close it from the account settings, or close it from the Organizations console. AWS keeps a closed account recoverable for a limited period before it is removed, so check the current rules first.
What I’d Do Next
Enable a model and make a first call to Amazon Bedrock from this sandbox account, from the console, the CLI and Python. That is the next post.