aws_multi_account
Run the same AWS API operation across multiple accounts in parallel by assuming a specified role in each. Returns per-account results with partial failures reported.
Instructions
Run the same AWS API operation across multiple ACCOUNTS in parallel by assuming the same role name in each. Same shape as aws_call (service, operation, params?, query?, outputFormat?, region?, timeoutMs?) plus accounts: string[] of 12-digit account IDs and roleName. This is fan-out in one call, not new access: it is exactly what aws_assume_role in a loop would reach, minus the credentials-file churn -- each account's session is held in memory for the one subprocess that uses it and is NEVER written to ~/.aws/credentials, so a sweep that dies halfway leaves nothing on disk. If your org already runs a Config aggregator or Resource Explorer, those answer indexed inventory questions with less work; reach for this when you want an arbitrary API operation across accounts with no setup. Returns an array of {accountId, ok, data?, command?, error?, errorKind?} -- partial failure is expected and normal (the role may not exist in every account, trust policies differ, services vary). Duplicate account IDs collapse (first occurrence wins), so use the returned accountCount. The batch is capped at 5 MB of results: past that, entries keep their status but lose data and are flagged truncated: true, with the affected accounts listed in a top-level truncatedAccounts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | JMESPath expression for --query (server-side trimming per account). | |
| params | No | Operation parameters (PascalCase keys) -- same shape as aws_call. | |
| region | No | Region for BOTH the sts:AssumeRole call and the operation. Defaults to the session region. | |
| profile | No | Profile to assume FROM -- your own identity, used for every sts:AssumeRole in the batch. Defaults to the session profile / $AWS_PROFILE. The target accounts never use a profile at all. | |
| service | Yes | AWS service in kebab-case: 's3api', 'ec2', 'iam', etc. | |
| accounts | Yes | Target AWS account IDs, 12 digits each (e.g. ['111111111111','222222222222']). 1-32. A malformed ID fails only its own entry and does not spawn a CLI call. | |
| roleName | Yes | Name of the role to assume in EVERY target account (e.g. 'OrganizationAccountAccessRole', 'ReadOnlyAuditor'). Combined with each account ID into arn:aws:iam::<account>:role/<roleName>. Include the IAM path if the role has one ('engineering/Auditor'). | |
| operation | Yes | Operation in kebab-case: 'describe-instances', 'get-caller-identity', 'list-buckets', etc. | |
| timeoutMs | No | Timeout in ms applied PER aws CLI spawn. Each account makes two: the sts:AssumeRole and the operation. Unset, the assume gets 120000 ms (headroom for cold-start SAML / credential_process) and the operation gets the standard 60000 ms; setting this applies one value to both. | |
| concurrency | No | Max accounts in flight at once (1-32). Default 8. | |
| sessionName | No | Role session name recorded in each target account's CloudTrail. Default 'aws-mcp-multi-account'. Alphanumeric + +=,.@- only, 2-64 chars. | |
| outputFormat | No | Output format. Default 'json'. |