Prerequisites
- An AWS account where you can create IAM roles (or IAM users, for the access-key method).
- Access to AWS CloudShell in that account. The setup script runs there, so you install nothing.
- For cost questions and Optimize: Cost Explorer turned on in the account (Billing and Cost Management → Cost Explorer → Launch Cost Explorer, in the management account for an organization). AWS can take up to 24 hours to activate it on a new account.
- In an AWS Organization, check your service control policies (SCPs). An SCP that denies
sts:AssumeRolefrom outside principals blocks the role, and one that denies regions hides those regions from agents. From the management account, list the SCPs on the account under AWS Organizations → AWS accounts → your account → Policies, or runaws organizations list-policies-for-target --target-id <account-id> --filter SERVICE_CONTROL_POLICY. - Opt-in regions, such as
ap-east-1orme-south-1, are invisible to agents until you enable them under Account → AWS Regions in the AWS console.
Setup
Open the connect dialog first: in the sidebar, click More → Workspace settings → Connections, select Amazon Web Services, and click Connect. Then follow the tab for the method you pick at the top of the dialog.- Role-Based (recommended)
- Access Keys
The dialog generates an External ID (a unique identifier that ties your role to this CloudThinker workspace and prevents the confused-deputy problem; AWS doesn’t treat it as a secret) and builds a setup script around it.Prefer to create the role yourself, for example in Terraform or CloudFormation? Expand Manual steps in the dialog. It shows the trust policy with your External ID and the CloudThinker principal filled in. The principal is the same for every workspace. Only the External ID changes with each dialog. With manual steps you can use any role name, because CloudThinker uses the ARN you paste. The shape is:The same role in Terraform, with both values passed in as variables:Copy both values from an open dialog, and keep that dialog open until
1
Name the account
Fill in Alias (for example
production) and Description (for example Production AWS account, main workloads). Agents read the description to pick the right account. Default AWS region (optional) is only a starting point: agents can use any region the role can reach.2
Open CloudShell
Click Open CloudShell and sign in to the AWS account you want to connect.
3
Run the setup script
To read the script first, click View script in the dialog. Then click Copy Script to Clipboard, paste it into CloudShell, and press Enter. The script:
The end of the output looks like this:
- Stops if a role named
CloudThinkerAccessRolealready exists. - Creates
CloudThinkerAccessRolewith a trust policy that only CloudThinker can assume, and only with your External ID. - Attaches the AWS managed
ReadOnlyAccesspolicy. - Prints the role’s ARN.
The full script, for review before you run it
The full script, for review before you run it
The dialog fills in your External ID and the CloudThinker principal. It also prints progress messages, left out here.
4
Paste the Role ARN and connect
Paste the ARN into AWS Role ARN. Leave AWS External ID as it is: it’s filled in for you and must match the script. Click Connect.Success state: the status moves through Connecting and Verifying, and the account shows a Connected status. Discovery now runs once in the background and spends credits. Check the Discovery section on the detail panel before your first prompt. See What happens after you connect.
5
Set the environment
Open Amazon Web Services in More → Workspace settings → Connections, click the pencil icon on the account’s row, and set Environment in Edit Instance. It labels the account for people and agents. See Set the environment.
6
Ask a verification question
Open a chat and ask the verification question. The answer should name your real 12-digit account ID.
terraform apply finishes and you’ve pasted the role_arn output into AWS Role ARN.The dialog has no timer, but the External ID lives only in that open browser tab. Closing the dialog or reloading the page loses it, and there’s no way to bring an External ID back into a new dialog. That’s a limitation for pull-request-reviewed Terraform, where apply can run hours later in CI: keep the dialog open until the pipeline finishes, or start a fresh dialog and update the trust policy’s External ID before you click Connect.Connect more accounts
Each AWS account is its own connection. Click Connect again on Amazon Web Services, give the account its own alias, and run the script from that dialog in the new account’s CloudShell. Always copy the script from the dialog you’re completing, so the trust policy carries the External ID that dialog shows. Bulk onboarding isn’t supported yet. Each dialog generates its own External ID, so a StackSet or a single Terraform apply can’t create roles for several connections at once. Each account needs its own dialog and its own role. For many accounts, the fastest path is the Terraform module above, applied once per account with the values from that account’s open dialog. For costs across an AWS Organization, connect the management account. That gives Optimize organization-wide cost only. Agents see resources in a member account only through that account’s own connection.Connection details
Environment (Production, Staging, Development, or Not set) isn’t in the connect dialog. Set it after connecting, as in the last setup step: it labels the account for people and agents. Approval rules don’t read it, so a Rule that should cover one account names that connection.
Required permissions
The setup scripts attach the AWS managedReadOnlyAccess policy. It lets agents describe and list resources across services, read CloudWatch metrics, and read Cost Explorer. It can’t create, change, or delete anything.
To switch an existing role to the narrower set, run this in CloudShell:
read_only attachment with attachments for those two policy ARNs and an aws_iam_role_policy holding the ce:Get* statement.
Agent capabilities
Verify the connection
Example prompts
Write access
Allow writes on the connection’s detail panel controls whether agents may change anything in AWS. It’s on by default for AWS, but the role the script creates is read-only, so AWS itself refuses every write until you grant more.
To lock writes in CloudThinker as well, open Amazon Web Services in More → Workspace settings → Connections and turn off the Allow writes switch on its detail panel.
Troubleshooting
The script says CloudThinkerAccessRole already exists
The script says CloudThinkerAccessRole already exists
Cause: an earlier setup in this account created the role, likely with a different External ID.Fix: if no other CloudThinker connection uses that role, remove its policies and delete it, then run the new script. To check whether a CloudThinker connection still uses the role, open CloudTrail Event history, filter Event name =
delete-role fails until every attached and inline policy is gone, so list them first:AssumeRole, and look for recent events on CloudThinkerAccessRole with a session name starting cloudthinker-. If one does, don’t replace its External ID. Use Manual steps to create a second role with a different name for this workspace instead.The test fails with AccessDenied on sts:AssumeRole
The test fails with AccessDenied on sts:AssumeRole
Cause: the trust policy doesn’t match what CloudThinker presents.Check: the ARN you pasted is the one the script printed, and the trust policy’s
sts:ExternalId matches AWS External ID in the dialog exactly.Fix: a failed test doesn’t save the connection. Correct the trust policy, then click Connect again in the same dialog so the External ID stays the same. If you closed the dialog, re-run the setup from a fresh one. Retry appears only on a saved connection that later shows Error.The connection shows Error and scheduled work stopped
The connection shows Error and scheduled work stopped
Cause: three background credential failures in a row (a deleted role, a broken trust policy, or a revoked key) switch the connection to Error. Optimize cost refreshes, scheduled automations, and Pulse polling pause for it, and workspace admins get one notification.Fix: repair the role or key in AWS, then click Retry on the connection, or Replace credentials to enter new keys. Scheduled work resumes on its next cycle once the status is Connected.
Cost questions return no data
Cost questions return no data
Check: Cost Explorer is turned on in the AWS Billing console, and at least 24 hours have passed since you turned it on. For a member account in AWS Organizations, the management account may block member access to Cost Explorer.Fix: turn on Cost Explorer, or connect the management account to see costs for the whole organization.
The test shows Timed out
The test shows Timed out
Cause: the test didn’t finish in time. AWS endpoints are public, so it’s rarely your network.Fix: connect again. If it keeps timing out, contact us.
A region or service returns AccessDenied with an explicit deny
A region or service returns AccessDenied with an explicit deny
Cause: a service control policy blocks it. The AWS error says the request was denied
with an explicit deny in a service control policy. If the SCP denies sts:AssumeRole, the test itself fails.Check: list the SCPs on the account, as in Prerequisites.Fix: ask your AWS Organizations admin to exempt CloudThinkerAccessRole from the SCP, or accept that agents can’t see that region or service.Security
- Least privilege — grant only the permissions the agents need for your use case; start read-only and widen later.
- Read-only by default — use read-only credentials unless you want agents to make changes through this connection.
- Rotate credentials — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
- Revoke on offboarding — remove the credential at the provider when you delete a connection or a teammate leaves.
- Prefer the role. CloudThinker assumes the role through AWS STS and gets short-lived credentials, so there’s no long-lived secret to leak. The External ID stops anyone else from using your role through CloudThinker.
- Audit with CloudTrail. Every call agents make is an ordinary AWS API call. CloudThinker names each role session
cloudthinker-<first 8 characters of your workspace ID>-<Unix timestamp>, and CloudTrail Event history shows that session name as the User name. To see every call across sessions, filter onuserIdentity.sessionContext.sessionIssuer.userName=CloudThinkerAccessRolein CloudTrail Lake or Athena. For access keys, filter Event history by User name =CloudThinkerUser.
Related
Optimize quickstart
Turn this connection into cost findings and savings recommendations.
Connections
Rotate credentials, set the environment, and read Discovery results.
Approvals
Decide which changes need a person before you grant any write permission.