Skip to content

AWS setup & CLI auth ​

Set up local access to Luna's AWS accounts and authenticate with the CLI. Complete this before running luna CLI commands, connecting to Aurora, or doing anything else that talks to AWS directly.

Accounts ​

The Luna platform uses 3 AWS accounts:

  • luna-non-prod — holds all the infrastructure of our lower environments
  • luna-production — holds all the infrastructure of our production environment
  • sandbox — used for DR exercises and core infrastructure change testing

Roles ​

There are two levels of access to these accounts:

  • Admin — everything
  • Developer — read only to most things

Speak with Artiom Nistrean to get assigned the correct level of access.

1. Configure ~/.aws/config ​

Before you can authenticate, set up the SSO session and profiles in your ~/.aws/config:

ini
[sso-session and-digital]
sso_start_url = https://d-9367673933.awsapps.com/start/#
sso_region = eu-west-1
sso_registration_scopes = sso:account:access

[profile luna-non-prod]
sso_session = and-digital
sso_account_id = 851725171061
sso_role_name = AdministratorAccess
region = eu-west-1
output = json

[profile luna-production]
sso_session = and-digital
sso_account_id = 666243557741
sso_role_name = AdministratorAccess
region = eu-west-1
output = json

2. Authenticate ​

With the config in place, authenticate once per session with AWS SSO, then export the profile for the account you're targeting:

bash
aws sso login --sso-session and-digital

export AWS_PROFILE=luna-non-prod    # non-prod AWS: polaris, sol, pulsar, staging
export AWS_PROFILE=luna-production  # production AWS

3. Verify and use it ​

With the profile exported, AWS CLI commands and the Luna CLI both pick up the credentials automatically — the Luna CLI assumes the correct role for the target environment for you. See running and testing CLI scripts for how to run a script or command against a specific environment.

4. Claude Code AWS profiles ​

In the Luna repo, Claude Code runs AWS commands inside its sandbox through a limited role per environment, <env>-platform-claude-role. Those commands run without a permission prompt. The sandbox can't read ~/.aws, so your admin credentials stay out of Claude's reach. When Claude needs your admin profile, it has to run outside the sandbox, and a hook asks you first.

You need python3 and an AWS CLI v2 that has aws configure export-credentials.

The role can list and describe resources across the account, and read data (DynamoDB items, S3 objects, logs) for its own environment only. It can't read secrets.

On the team environments (polaris, sol and pulsar) the role can also write test data, so Claude can test a change end to end. It can write and delete DynamoDB items, put and delete S3 objects (but not in the deployments bucket or the buckets that host the clients), invoke Lambda functions, publish to SNS topics, and read, delete and redrive messages on dead-letter queues. All of this is limited to that environment's resources. Claude removes the test data it creates. On staging and production the role is read-only.

Add the profiles ​

Add these to your ~/.aws/config, below the profiles from step 1. Replace <firstname.lastname> with your own name, so CloudTrail shows which calls Claude made for you.

ini
[profile polaris-platform-claude-profile]
source_profile = luna-non-prod
role_arn = arn:aws:iam::851725171061:role/polaris-platform-claude-role
role_session_name = claude-<firstname.lastname>
region = eu-west-1

[profile sol-platform-claude-profile]
source_profile = luna-non-prod
role_arn = arn:aws:iam::851725171061:role/sol-platform-claude-role
role_session_name = claude-<firstname.lastname>
region = eu-west-1

[profile pulsar-platform-claude-profile]
source_profile = luna-non-prod
role_arn = arn:aws:iam::851725171061:role/pulsar-platform-claude-role
role_session_name = claude-<firstname.lastname>
region = eu-west-1

[profile staging-platform-claude-profile]
source_profile = luna-non-prod
role_arn = arn:aws:iam::851725171061:role/staging-platform-claude-role
role_session_name = claude-<firstname.lastname>
region = eu-west-1

[profile production-platform-claude-profile]
source_profile = luna-production
role_arn = arn:aws:iam::666243557741:role/production-platform-claude-role
role_session_name = claude-<firstname.lastname>
region = eu-west-1

The role trusts the AdministratorAccess SSO role only.

Check it works ​

After aws sso login --sso-session and-digital, run this in your own terminal:

bash
aws --profile polaris-platform-claude-profile sts get-caller-identity

The Arn in the output should end in polaris-platform-claude-role/claude-<firstname.lastname>.

How Claude uses them ​

Before Claude runs an AWS command that names one of these profiles, a hook (.claude/hooks/refresh_claude_aws_credentials.py) exports short-lived keys for it into ~/.aws-claude/luna/credentials, which the sandbox can read. It only does that if the profile's role_arn really is the Claude role. The keys last an hour and are refreshed automatically. If a refresh fails, for example because your SSO session has expired, Claude tells you why.

Claude follows .claude/rules/aws.md to pick these profiles. .claude/hooks/guard_aws_admin.py asks you before an AWS command (aws, sam, boto3 or an AWS_ variable) that runs outside the sandbox or names luna-non-prod / luna-production. It works by matching text, so it's a safety net: AWS use it can't spot still goes through Claude Code's normal permission checks.

One known exception: the service-review-costs skill script runs outside the sandbox through sandbox.excludedCommands, reads Cost Explorer with your admin profiles, and is approved automatically. If you turn the sandbox off, the hook only catches commands that name an admin profile.

Environments ​

There are a number of Luna environments. Several are team environments used by the core platform teams to test and demo their code; beyond those, two are worth focusing on:

  • Staging — used for integration testing of all new functionality before production release
  • Production — the live environment, used by ANDis across the company

Release process ​

Git and release process

Made with ❤️ by the Luna team