Skip to content
AWS

A Safe AWS Sandbox Account with IAM Identity Center

A separate account for experiments, signed in with short-lived credentials instead of access keys

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

  1. A sandbox account created under AWS Organizations
  2. IAM Identity Center with one user and one permission set
  3. A CLI profile that signs in with aws sso login and 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:

bash
aws organizations create-organization --feature-set ALL

aws organizations create-account \
  --account-name sandbox \
  --email you+sandbox@example.com

Account creation is asynchronous. Check progress with:

bash
aws organizations list-accounts --query "Accounts[].[Name,Id,Status]" --output table

Step 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.

  1. Open IAM Identity Center in the management account, with your chosen Region selected
  2. Choose Enable (the organization from Step 1 must already exist)
  3. On the next page you choose an instance configuration. In Regions that support multi-Region, there are three options:
OptionWhat you getCost note
Single-Region instanceInstance in the current Region only. Data encrypted with an AWS owned key. You can add Regions later from Settings.No extra charge
Multi-Region instanceInstance 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 instanceYou 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.

  1. Under Users, create a user for yourself and set up MFA for it

Step 3: Give Yourself Access to the Sandbox

  1. Under Permission sets, create one. I start with the AWS managed PowerUserAccess policy, which allows everything except IAM and Organizations management
  2. 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:

bash
aws configure sso

It asks for the following:

PromptWhat to enter
SSO session nameAny name, for example renegade
SSO start URLThe AWS access portal URL you just copied
SSO regionThe primary Region you enabled Identity Center in (Step 2). This is not necessarily where you will build things
SSO registration scopesPress 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:

bash
aws sso login --profile sandbox
aws sts get-caller-identity --profile sandbox

The 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:

bash
aws cloudformation deploy \
  --profile sandbox \
  --region eu-west-2 \
  --template-file budget.yaml \
  --stack-name monthly-budget \
  --parameter-overrides BudgetAmount=10 AlertEmail=you@example.com

What 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.