ECR Scan-on-Push Disabled
ecr-scan-on-push-disabled
What this rule checks
Detects ECR repositories without image vulnerability scanning on push.
How to fix it
- 1Enable ScanOnPush in ImageScanningConfiguration
- 2Or use enhanced scanning at the registry level
import * as ecr from 'aws-cdk-lib/aws-ecr';
const repo = new ecr.Repository(this, 'Repo', {
repositoryName: 'app-images',
imageScanOnPush: false,
});import * as ecr from 'aws-cdk-lib/aws-ecr';
const repo = new ecr.Repository(this, 'Repo', {
repositoryName: 'app-images',
imageScanOnPush: true,
});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::ECR::RepositoryIntentional? Suppress this finding
Sometimes a flag is deliberate โ a genuinely public endpoint, say. You can dismiss ecr-scan-on-push-disabled and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "ecr-scan-on-push-disabled", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::ecr-scan-on-push-disabled',
reason: 'Why this is intentional',
});Use the rule ID ecr-scan-on-push-disabled 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.