Connect AWS with One CloudShell Command
One command deploys the same CloudFormation stacks as Launch Stack in AWS, using your own AWS session. There's no file to send back: the portal detects the connection once the stack completes.
It needs only AWS CLI v2, so it runs in AWS CloudShell as is.
Run It In CloudShell
-
In Spotto, select Create, then AWS. Under Script or Terraform, select Use CloudShell, choose Cost Data and copy the command. It includes your deployment, registration topic, External ID and trusted principal ARN. Neither is a secret.
-
Sign in to the AWS console in the management account (or the standalone account) and open CloudShell.
-
Paste the command:
curl -fsSL https://raw.githubusercontent.com/spottoai/spotto-tools/main/onboarding/aws/connect.sh | bash -s -- \--deployment <deployment from the portal> \--registration-topic-arn <topic ARN from the portal> \--external-id spotto-<uuid> \--trusted-principal-arn <ARN shown in the portal> -
Answer the questions. Press Enter to accept each default.
-
Leave the portal on Waiting for the connection…. It detects the connection when the stack completes. Choose the accounts and select Finish.
Ran the command earlier, or closed the portal? Open Connect AWS again: the portal offers the detected account. Select Continue. If it isn't offered, select Enter Account ID.
What It Does
- Checks your session with
aws sts get-caller-identityand prints the account. - Detects whether it's a management, member or standalone account.
- Asks the questions below.
- Checks for problems that would fail halfway, such as an existing role or export with the same name.
- Shows the plan and asks before deploying.
- Creates/updates regional access and member stacks, then the separate us-east-1 export-definition stack for new billing. It waits for each; CUR files stay in the mapped region.
| Question | Default | Asked when |
|---|---|---|
| Continue with this account only? | Yes | It's a member account. Connect the management account instead to see the whole organization. |
| Create a new billing export (recommended)? | Yes | Always. No lists your existing supported exports to choose from. |
| Also connect every member account (StackSet)? | Yes | It's the management account. Turns on StackSets trusted access if needed. |
| Deploy now? | Yes | Always, after the plan. |
For an existing export, it checks the export is Parquet and detects a customer-managed KMS key on the bucket.
Options
Every question has a flag, so the command can run unattended.
| Bash | PowerShell | What it does |
|---|---|---|
--external-id <id> | -ExternalId | Your External ID, from the portal. Required. |
--trusted-principal-arn <arn> | -TrustedPrincipalArn | The trusted principal ARN, from the portal. Required. |
--profile <name> | -Profile | AWS CLI profile. Default: the current session. |
--cost-data create|existing | -CostData | Create a new export, or use an existing one. Billing is required, so none is rejected for a new connection. |
--export-arn <arn> | -ExportArn | The existing export to use. Implies existing. |
--connect-members yes|no | -ConnectMembers | Deploy the role to member accounts. Management account only. |
--organizational-unit-ids <ids> | -OrganizationalUnitIds | Comma-separated root or OU IDs. Default: the organization root. |
--role-name <name> | -RoleName | Default SpottoReadOnlyRole. Keep the default: the portal looks for this name. |
--yes | -Yes | Ask nothing. Use the defaults and flags. |
--check | -Check | Change nothing. Report template versions, drift and member account status. See check. |
--repair | -Repair | Reapply the role's trust policy and policies, or recreate a deleted role. See repair. |
--enable <capability> | -Enable | Turn on an optional capability. None exist yet. |
Unattended example, for an organization with a new export:
curl -fsSL https://raw.githubusercontent.com/spottoai/spotto-tools/main/onboarding/aws/connect.sh | bash -s -- \
--external-id spotto-<uuid> --trusted-principal-arn <ARN> \
--cost-data create --connect-members yes --yes
With --cost-data existing --yes and more than one export, pass --export-arn.
PowerShell
In CloudShell, enter pwsh first. Locally, you need PowerShell 7 and AWS CLI v2.
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/spottoai/spotto-tools/main/onboarding/aws/Connect-SpottoAws.ps1" -OutFile ./Connect-SpottoAws.ps1
./Connect-SpottoAws.ps1 -ExternalId spotto-<uuid> -TrustedPrincipalArn <ARN shown in the portal>
It asks the same questions and takes the same options.
Run It Locally
Sign in first, for example with aws sso login --profile <name>, then pass --profile <name>. To review the script before running it, download it:
curl -fsSLO https://raw.githubusercontent.com/spottoai/spotto-tools/main/onboarding/aws/connect.sh
bash connect.sh --external-id spotto-<uuid> --trusted-principal-arn <ARN> --profile <name>
The source and README are in spotto-tools on GitHub.
Troubleshooting
| Message | Fix |
|---|---|
| Can't read your AWS session. Sign in first | Run aws sso login, or use CloudShell. |
| An IAM role named SpottoReadOnlyRole already exists | An earlier setup created it. Delete the role in IAM, then rerun. |
| An export named spotto-cur2 already exists | Rerun with --cost-data existing, or delete the old export. |
| Export … isn't Parquet | Parquet is required. Rerun with --cost-data create. |
| No billing exports found in this account | Rerun with --cost-data create. |
| A message that billing is required | --cost-data none isn't accepted. Rerun with --cost-data create, or --cost-data existing and an --export-arn. An older stack created without billing warns on update with the same advice. |
| Several exports found. Pass one with --export-arn. | Add --export-arn. Find the ARN. |
| No terminal for questions | Rerun with --yes and the flags you need. |
| StackSets trusted access isn't turned on | Turn it on in CloudFormation > StackSets > Enable trusted access, or run aws cloudformation activate-organizations-access --region <owning-region>. Then rerun. |
Stack SpottoConnect-<deployment> failed with SpottoRegistration | The External ID isn't from this company or environment. Copy the command from the portal again and rerun. See registration timed out. |
| Stack … failed | The first errors are printed. See CloudFormation troubleshooting. |
Rerunning is safe. Stacks that already exist are updated to the latest template, keeping their settings, and a stack left over from a failed attempt is removed first. See update and repair.
Regional Binding
--deployment / -Deployment is required for connect, check and repair. Copy it
from Portal: dev-au/prod-au use Sydney, prod-us N. Virginia, prod-eu Stockholm.
The registration topic must match that deployment. Defaults for roles, stacks,
buckets and export names include the deployment suffix. See template responsibilities.