IAM Cross-Account Trust
iam-cross-account-trust
What this rule checks
Detects IAM roles with cross-account trust relationships.
How to fix it
- 1Verify cross-account trust is intentional
- 2Add conditions to restrict access (e.g., external ID)
- 3Document the business justification
import { Role, ArnPrincipal } from 'aws-cdk-lib/aws-iam';
new Role(this, 'PartnerAccessRole', {
assumedBy: new ArnPrincipal('arn:aws:iam::111122223333:root'),
});import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
new Role(this, 'PartnerAccessRole', {
assumedBy: new ServicePrincipal('lambda.amazonaws.com'),
});CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.
Affected resource types
AWS::IAM::RoleIntentional? Suppress this finding
Sometimes a flag is deliberate โ a genuinely public endpoint, say. You can dismiss iam-cross-account-trust and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "iam-cross-account-trust", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::iam-cross-account-trust',
reason: 'Why this is intentional',
});Use the rule ID iam-cross-account-trust shown above โ not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs โ
Catch this in your stack
$ npx cdk-insights scanCDK Insights runs this and 118+ other rules locally against your synthesised CDK app โ free, no account, your code never leaves your machine.