Skip to Content
IntegrationsCloudAWSServerless

Scan Multiple AWS Accounts from One Hub

Configure the Mondoo serverless AWS integration to scan many AWS accounts from a single hub account using a cross-account IAM role.

Cross-account scanning lets you run the Mondoo serverless scanner in a single AWS hub account and have it inventory and assess resources across many other AWS accounts in your AWS Organization. You control which accounts are scanned and how often, all from one integration.

The typical shape: one hub account (often the AWS Organizations management account) hosts the Mondoo CloudFormation stack. Every other target account hosts only a small IAM role that the hub scanner assumes. The role reads AWS APIs and, unless you turn it off, can snapshot EBS volumes for OS-level scans of EC2 instances. No Mondoo software runs in the target accounts.

Cross-account scanning differs from the organization install, which deploys the Mondoo Lambda into every account via a CloudFormation StackSet. With cross-account scanning, the Mondoo Lambda runs in one hub account only and assumes a cross-account role in each target account.

How it works

  1. You create a cross-account IAM role in every account you want scanned. Its trust policy allows only Mondoo's hub-side scanner role to assume it.
  2. You enable cross-account scanning on a Mondoo AWS integration and provide the cross-account role name and the list of target accounts (or let Mondoo auto-discover them via AWS Organizations).
  3. You deploy the Mondoo CloudFormation stack in the hub account.
  4. On each scan cycle (default: every 12 hours), the Mondoo Lambda in the hub assumes the cross-account role in each target account, inventories resources read-only, and reports findings back to Mondoo Platform.

The security boundary is the cross-account IAM role's trust policy. Mondoo configures it so that only its specific scanner role in your hub account can assume the cross-account role. Not the hub account root, and not any other principal in the hub account.

Before you begin

Before you start, confirm:

  • An AWS Organization. The recommended StackSets path and account auto-discovery both use it. If you don't have one, contact Mondoo support to discuss alternatives.

  • A chosen hub account. Typically your AWS Organizations management account, but any account you own will do. The Mondoo CloudFormation stack is deployed in this account and only this account. You cannot have two hubs in the same organization using the same integration.

  • CloudFormation StackSets trusted access enabled (for the recommended StackSets deployment path). This is a one-time toggle in the management account. See Enabling trusted access with AWS Organizations in the AWS documentation. Equivalent CLI:

    aws organizations enable-aws-service-access \
      --service-principal stacksets.cloudformation.amazonaws.com
  • Admin access to target accounts (for the script-based fallback path). The script needs a role it can assume in each target account with iam:CreateRole, iam:AttachRolePolicy, and iam:TagRole permissions. The OrganizationAccountAccessRole role (created automatically in every account added via AWS Organizations) is the typical choice.

Step 1: Create the cross-account role in every target account

You have two options. StackSets is the recommended path for any customer using AWS Organizations.

Use the same role name here and in Step 2. Read Role name must match everywhere.

Mondoo publishes a CloudFormation template for the cross-account role with every release. Deploy it as a service-managed StackSet from your management account, targeting either your entire organization or a specific organizational unit (OU). Use the copy in the region where you create the StackSet:

  • us-east-1: https://s3.amazonaws.com/mondoo.us-east-1/cross-account-target-role.json
  • Other supported regions: https://s3.<region>.amazonaws.com/mondoo.<region>/cross-account-target-role.json

These URLs always serve the current template. To update an existing StackSet to it, read Update the stack to the current template.

The template accepts these parameters:

ParameterDescriptionDefault
HubAccountIdThe AWS account ID where the Mondoo CloudFormation stack will be deployed.(required)
RoleNameName of the cross-account role to create.MondooCrossAccountScan
ScannerRoleNameName of the hub-side Mondoo scanner role. Almost never needs to change.mondoo-account-scanner-role
PermissionsPolicyAWS-managed policy to attach: SecurityAudit or ReadOnlyAccess. See Choose the permissions policy.SecurityAudit
EbsScanningOS-level scans of EC2 instances through EBS snapshots: true, unencrypted-only, or false. See EBS scanning of target instances.true
OrganizationIdDeprecated and ignored. Still accepted so that existing StackSets keep updating. Leave it empty.(empty)
MaxSessionDurationDeprecated and ignored. Still accepted so that existing StackSets keep updating. The role keeps the IAM default session limit of one hour.3600

A typical CLI deployment:

aws cloudformation create-stack-set \
  --stack-set-name mondoo-cross-account-scan \
  --template-url https://s3.amazonaws.com/mondoo.us-east-1/cross-account-target-role.json \
  --permission-model SERVICE_MANAGED \
  --auto-deployment Enabled=true,RetainStacksOnAccountRemoval=false \
  --capabilities CAPABILITY_NAMED_IAM \
  --parameters \
      ParameterKey=HubAccountId,ParameterValue=123456789012

aws cloudformation create-stack-instances \
  --stack-set-name mondoo-cross-account-scan \
  --deployment-targets OrganizationalUnitIds=ou-xxxx-xxxxxxxx \
  --regions us-east-1

After the StackSet finishes deploying, the cross-account role exists in every targeted account with the same name, trust policy, and permissions. New accounts that join the targeted OU are auto-provisioned with the role.

Option B (fallback): the setup script

For ad-hoc account lists or iterative testing, Mondoo ships a setup-cross-account-roles.sh script that produces the same role, trust policy, and managed-policy attachment as the StackSets template. The script doesn't grant the EBS scanning permissions, so a role it creates stays read-only. Use the template for EBS scanning.

A typical invocation:

./setup-cross-account-roles.sh \
  --hub-account-id 123456789012 \
  --accounts-file ./target-accounts.txt \
  --role-name MondooCrossAccountScan \
  --permissions-policy SecurityAudit \
  --admin-role-name OrganizationAccountAccessRole

./target-accounts.txt is a plain-text file with one account ID per line. You can also omit --accounts-file and pass --from-organizations to enumerate every ACTIVE account in your organization (excluding the hub). One of the two is required.

Earlier versions of the script took --organization-id and --max-session-duration. The script still accepts both, ignores them, and prints a warning. Drop them from your invocation, because a future release removes them.

The script is idempotent. Re-running it reconciles the trust policy, session limit, tags, and attached managed policy in place, so it's safe to re-run whenever you change policy or add accounts. Pass --dry-run to preview changes without calling AWS. At the end of the run, the script prints a per-account summary showing which accounts succeeded and which need attention.

Step 2: Enable cross-account scan on the Mondoo integration

When you create a serverless AWS integration, go to Configure cross-account scanning, turn on Enable cross-account scanning, and provide the matching role name and target accounts.

Cross-account scanning settings in the serverless AWS integration form: IAM role name, target account IDs, and account tags

Configure these settings:

SettingDescription
Enable cross-account scanningTurn on to scan additional AWS accounts from this hub.
IAM role nameRequired. The exact name of the role you created in Step 1. Mondoo passes it to the hub stack as the CrossAccountScanRoleName parameter. You can't change it in the integration after you create it.
Target account IDsThe explicit list of accounts to scan, one account ID per line. Leave empty to let Mondoo auto-discover accounts via AWS Organizations on every scan cycle.
Account tagsOptional. Only scan discovered accounts that match at least one of these AWS account tags. Enter each tag as Key=Value on a new line. Repeat a key on multiple lines to match any of its values, or use Key=* to match a key regardless of its value.

The IAM role name must match the role name in every target account. Read Role name must match everywhere.

Step 3: Deploy the hub stack

After you select START SCANNING, Mondoo shows a LAUNCH CLOUDFORMATION button.

  1. Sign in to the hub account in the AWS console.

  2. In Mondoo, select LAUNCH CLOUDFORMATION. It opens a pre-filled CloudFormation quick-create page.

  3. Review the pre-populated parameters. Confirm that CrossAccountScanRoleName is the exact role name you deployed in Step 1. Then acknowledge the IAM capabilities and create the stack.

Stack creation takes 3 to 5 minutes. When the stack finishes, the hub account contains:

  • The Mondoo Lambda, which enumerates target accounts and launches scans.
  • An EC2 scanner role named mondoo-account-scanner-role. This is the role whose ARN the target-account trust policies allow.
  • SQS queues and supporting IAM roles.

Step 4: Verify the integration

Within 30 minutes of stack creation, the integration's status in the Mondoo App should change to Active, and assets for each target account should appear in Mondoo. If an account doesn't appear, read Troubleshoot.

Critical constraints

These rules, if violated, prevent scans from completing.

Role name must match everywhere

The hub scanner assumes the role named by the CrossAccountScanRoleName parameter of the Mondoo CloudFormation stack in the hub account. The hub's IAM policy lets it assume only a role with that name. The name must be identical in two places:

  • The RoleName parameter of the StackSets template (or the --role-name flag of the setup script), which names the role in every target account.
  • The CrossAccountScanRoleName parameter of the hub stack.

You don't enter the hub stack parameter by hand. When you create the integration, Mondoo fills it in from the IAM role name field: LAUNCH CLOUDFORMATION opens the quick-create page with CrossAccountScanRoleName set to the name you entered. Once the hub stack checks in, the integration page shows the name the stack uses in the Cross-account IAM role row of the INTEGRATION CONFIGURATION section. If CrossAccountScanRoleName is empty, the hub doesn't scan other accounts.

The template default (MondooCrossAccountScan) is fine for most customers. The IAM role name field starts empty. Its placeholder shows that default, but the placeholder isn't a value: type or paste the exact name you deployed.

Mondoo builds the cross-account role ARN as arn:aws:iam::<target-account>:role/<CrossAccountScanRoleName> for every target account. If the names drift apart, even by a one-character typo, Mondoo builds an ARN for a role that doesn't exist. AWS rejects every AssumeRole call for the affected account with AccessDenied (or NoSuchEntity), and scans for that account don't complete until you correct the mismatch. The integration in the Mondoo App shows the AWS error message along with the target account ID, so you can see which account is misconfigured.

The integration's edit form doesn't show the role name, so you can't fix a mismatch by editing the integration. Make both sides match in one of these ways:

  • Update the hub stack with its existing template and set CrossAccountScanRoleName to the role name in your target accounts.
  • Redeploy the StackSets template (or rerun the setup script) with the role name the hub stack already uses.

The same applies if you turn on Enable cross-account scanning for an integration you created without it: set CrossAccountScanRoleName on the hub stack too. Mondoo picks up the stack's role name the next time the Lambda checks in.

The hub account must match the trust policy

The StackSets template's HubAccountId parameter (and the script's --hub-account-id flag) is written into every target-account trust policy as the allowed principal. If you later move the Mondoo CloudFormation stack to a different hub account, you must re-deploy the StackSets template (or re-run the script) with the new HubAccountId before scans from the new hub will succeed.

Only one Mondoo hub per organization

Target-account trust policies allow a single hub account. If you deploy the Mondoo CloudFormation stack in two accounts and expect both to scan the same targets, only the account that matches the trust policy will succeed. The other gets AccessDenied.

Choose the permissions policy

The cross-account role gets its read access from exactly one AWS-managed policy. You have two choices:

SecurityAudit (default)ReadOnlyAccess
ScopeDescribe*, List*, Get*Policy, and other configuration-plane reads across AWS services.All reads. Includes s3:GetObject, dynamodb:Scan, secretsmanager:GetSecretValue, kms:Decrypt, sqs:ReceiveMessage, and other data-plane reads.
Blast radiusSmaller. Reads metadata, configuration, and policies. Does not read data-plane contents.Larger. Includes data-plane reads that a security scanner does not need.
Recommended forProduction.Rare cases where SecurityAudit turns out to be missing permissions for a specific service.

Mondoo's scanner is designed around configuration-plane reads. SecurityAudit is the right default and matches least-privilege best practice for this use case.

To switch policies, re-run the StackSets deployment (or the script) with PermissionsPolicy=ReadOnlyAccess (or --permissions-policy ReadOnlyAccess). Both are idempotent, so the only change is swapping the managed policy on the existing role.

EBS scanning of target instances

Besides reading AWS APIs, the cross-account role can let the hub scan the EC2 instances of a target account at the operating system level. The hub snapshots an instance's EBS volumes in the target account, shares the snapshots with the hub account, copies them there, and scans the copies. The EbsScanning template parameter sets what the role may do for this, per account:

ValueWhat the role may do
true (default)Snapshot EBS volumes, share the snapshots with the hub account, and delete them again. Encrypted snapshots are first copied onto a hub-owned KMS key.
unencrypted-onlyThe snapshot permissions, but no KMS permissions. Encrypted volumes are skipped, and the integration shows a warning with the number of volumes skipped.
falseNothing beyond the managed policy. The role stays read-only.

With true, snapshots of volumes encrypted with the AWS-managed aws/ebs key can't be shared across accounts, so the role first copies them onto a KMS key that the hub owns (alias/mondoo-ebs-scan in the hub account, one per region). That key's policy admits the role by name, only through EC2. Nothing is created in your account beyond the snapshots.

Whatever the value, the role is limited in these ways:

  • Every snapshot the role creates carries the tag mondoo:cross-scanner=ebs, and the role can share or delete only snapshots with that tag.
  • A share can name only the hub account. The role can't share a snapshot with any other account or make one public.
  • The snapshots in your account are deleted as soon as the hub holds its copy. No Mondoo compute runs in your account, and no volume leaves it.
  • The role creates, tags, or deletes no KMS key. It uses your own keys only through EC2 while a copy is made, and it can encrypt a copy under no key but the hub's.
  • A volume encrypted with a customer managed key whose key policy doesn't delegate to IAM can't be read. Mondoo skips it and shows a warning that names the key.

IAM can't restrict which snapshots CopySnapshot reads, so with EbsScanning=true the role could copy any snapshot your account owns onto the hub's key. Every such call appears in your CloudTrail, and a copy can be shared only with the hub account.

The permissions alone scan nothing. EBS scanning of target accounts is in beta and is off by default. Mondoo uses the permissions only while it's turned on for the integration. To try it, contact Mondoo, or turn it on yourself through the Terraform provider or the GraphQL API (the Mondoo App doesn't show this setting):

  • In the mondoo_integration_aws_serverless Terraform resource, set ebs_volume_scan in scan_configuration.cross_account_scan_options to true.
  • In the GraphQL API, set ebsVolumeScan in the integration's cross-account scan options to true.

The setting takes effect only while Scan the Lambda AWS Account, Enable cross-account scanning, and Use EBS volume scanning for instance scanning are all on, and only in target accounts whose role was deployed with EbsScanning set to true or unencrypted-only.

EBS scanning of target accounts also needs the Mondoo CloudFormation stack in the hub account at release 2.90.0 or later. The scanner updates its own code but not its stack, so a hub stack created from an earlier release needs a stack update to the current template. To learn how, read Update the stack to the current template.

Before release 2.97.0, the role re-encrypted onto a key it created in your account (alias/mondoo-ebs-scan, tagged mondoo=auto-gen-cmk). A role still on that earlier template can't encrypt under the hub's key, so Mondoo skips its encrypted volumes and shows a warning until you update the StackSet. The key the earlier role created stays in your account. Schedule its deletion yourself with aws kms schedule-key-deletion once no Mondoo snapshots remain.

Add and remove accounts

With StackSets:

  • Adding an account to your AWS Organization (or to the targeted OU) auto-provisions the role in that account. StackSets reconciles on account join.
  • Removing an account from the organization automatically removes the role (assuming RetainStacksOnAccountRemoval=false in the recommended deployment).
  • In the Mondoo integration, if you left Target account IDs empty (auto-discovery), the new account is picked up on the next scan cycle. If you provided an explicit list, add or remove the account ID in the integration configuration.

With the setup script:

  • Add or remove account IDs in target-accounts.txt, then re-run the script. Existing roles are updated in place, new ones are created, and removed accounts' roles remain (the script does not delete). To delete a cross-account role in an offboarded account, do it manually or by scripting a teardown in that account.
  • Update the Mondoo integration's Target account IDs field the same way.

Mondoo discovers new accounts on the next scheduled scan (default: within 12 hours). You do not need to manually re-trigger anything.

Scan accounts in other AWS Organizations

Auto-discovery finds the accounts of the hub account's own AWS Organization. A hub can also scan every active account of other AWS Organizations, in addition to its own. For each additional organization, the hub assumes the cross-account role in that organization's management (or delegated administrator) account and lists the organization's accounts from there. No extra role is needed.

The hub discovers other organizations only through auto-discovery, so leave Target account IDs empty. An explicit account list turns off all discovery, including the discovery of other organizations. Account tags, if you set them, filter the accounts of every organization.

To scan another organization:

  1. Deploy the cross-account role in the accounts of that organization, as described in Step 1. Use the same role name and HubAccountId as for your own organization.
  2. Deploy the role in the organization's management (or delegated administrator) account as well, because the hub lists the organization's accounts through it. A service-managed StackSet never deploys into the management account, so create the stack there directly. The SecurityAudit policy already includes the AWS Organizations read permissions the hub needs.
  3. Add the organization to the integration's cross-account scan options. Each entry maps an AWS Organization ID to the 12-digit ID of its management (or delegated administrator) account, for example o-abc123defg to 111111111111. The Mondoo App doesn't show this setting. Set it with the organizations map in scan_configuration.cross_account_scan_options of the mondoo_integration_aws_serverless Terraform resource, or with the organizations field of the cross-account scan options in the GraphQL API.

The hub stack must run the template from release 2.87.0 or later. To update it, read Update the stack to the current template.

If the hub can't list an organization's accounts, for example because it can't assume the role in the management account, it skips that organization for the scan cycle and shows a warning with the organization ID on the integration. The other organizations still scan.

Saving in the Mondoo App clears these settings

The Mondoo App's edit form doesn't keep the additional organizations or the setting for EBS scanning of target accounts. If you save the integration in the Mondoo App, set them again through Terraform or the GraphQL API.

Troubleshoot

The first place to look is the integration status in the Mondoo App. The Mondoo Lambda reports every AWS error it encounters, including the target account ID that was being scanned, so you can diagnose per-account without reading logs.

An account is missing from Mondoo after a full scan cycle

Open the integration's status view in the Mondoo App and look for errors referencing that account ID.

  • AccessDenied on sts:AssumeRole naming a specific role ARN. The role name in the target account doesn't match the hub stack's CrossAccountScanRoleName parameter, which the integration page shows in the Cross-account IAM role row. Check that both sides use the exact same string, character-for-character. To fix it, update CrossAccountScanRoleName on the hub stack, or redeploy the StackSets template (or rerun the script) with the name the hub uses. Editing the integration in Mondoo doesn't change the role name. See Role name must match everywhere.
  • AccessDenied on sts:AssumeRole but the role ARN looks correct. The trust policy's aws:PrincipalArn condition doesn't match the hub's scanner role ARN. Verify the HubAccountId and ScannerRoleName parameters you deployed with, then re-deploy the StackSets template or re-run the script with corrected values.
  • NoSuchEntity. The role doesn't exist in that account. The StackSets deployment or script run did not complete for that specific account. Re-deploy or re-run.

Every account is missing

If no accounts are scanning, the problem is almost certainly at the hub, not in the target accounts.

  • Confirm the Mondoo CloudFormation stack was deployed in the account whose ID you specified as HubAccountId when setting up the target-account roles.
  • Confirm the hub-side scanner role mondoo-account-scanner-role exists in the hub account. It's created by the Mondoo CloudFormation stack.
  • Check the integration status for an AWS Organizations error. If Mondoo is auto-discovering accounts and the hub Lambda can't reach AWS Organizations, discovery returns empty and no cross-account scans run.

An account scans but its findings are empty or partial

This is usually a permissions gap. If you chose SecurityAudit and a specific check is failing, switch the affected accounts to ReadOnlyAccess. See Choose the permissions policy. ReadOnlyAccess is guaranteed to cover all reads the scanner needs, at the cost of a broader policy.

Offboard cross-account scanning

To remove cross-account scanning:

  1. Edit the Mondoo integration and turn off Enable cross-account scanning (or delete the integration entirely).
  2. Delete the Mondoo CloudFormation stack in the hub account.
  3. Delete the StackSet that created the cross-account roles. This removes the role from every target account. If you used the setup script, delete the cross-account roles manually or by scripting a teardown.

Deleting the hub stack schedules the hub's alias/mondoo-ebs-scan keys for deletion, with a seven-day waiting period that the hub account's administrators can cancel. Nothing in the target accounts needs cleanup beyond the role.

Next steps

Last updated on

On this page