Image Builder AMI Shared With All AWS Accounts
imagebuilder-ami-public-launch-permission
What this rule checks
Detects Image Builder distribution configurations whose AMI launch permission includes the "all" user group, making the produced AMI public to every AWS account.
How to fix it
- 1Remove UserGroups: ["all"] from LaunchPermissionConfiguration
- 2Share with specific accounts (UserIds / TargetAccountIds) or your organization (OrganizationArns)
import * as imagebuilder from 'aws-cdk-lib/aws-imagebuilder';
new imagebuilder.CfnDistributionConfiguration(this, 'Dist', {
name: 'app-ami',
distributions: [
{
region: 'eu-west-2',
amiDistributionConfiguration: {
Name: 'app-ami-{{ imagebuilder:buildDate }}',
LaunchPermissionConfiguration: { UserGroups: ['all'] },
},
},
],
});import * as imagebuilder from 'aws-cdk-lib/aws-imagebuilder';
new imagebuilder.CfnDistributionConfiguration(this, 'Dist', {
name: 'app-ami',
distributions: [
{
region: 'eu-west-2',
amiDistributionConfiguration: {
Name: 'app-ami-{{ imagebuilder:buildDate }}',
LaunchPermissionConfiguration: { UserIds: ['111122223333'] },
},
},
],
});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::ImageBuilder::DistributionConfigurationIntentional? Suppress this finding
Sometimes a flag is deliberate โ a genuinely public endpoint, say. You can dismiss imagebuilder-ami-public-launch-permission and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "imagebuilder-ami-public-launch-permission", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::imagebuilder-ami-public-launch-permission',
reason: 'Why this is intentional',
});Use the rule ID imagebuilder-ami-public-launch-permission 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 136+ other rules locally against your synthesised CDK app โ free, no account, your code never leaves your machine.