Review ECR image vulnerability scanning

Scan stored images and address the findings.

Description

With scan_on_push disabled on an ECR repository, registry-level enhanced scanning or a manual scan may still cover the image. Check the effective scanning mode.

Potential impact

Images with known vulnerabilities can be deployed when scans or follow-up are missing.

Remediation

Configure basic or enhanced scanning for the intended repositories and verify a newly pushed image’s results. Update vulnerable packages and decide separately whether to deploy. Turning on scanning does not block deployment.

Examples

Both excerpts show basic scanning for service-image. Check the active registry rules and filters as well as the repository’s scan_on_push = true setting.

Before

hcl
resource "aws_ecr_repository" "example" {
  name                 = "service-image"
  image_tag_mutability = "MUTABLE"

  image_scanning_configuration {
    scan_on_push = false
  }
}

After

hcl
resource "aws_ecr_repository" "example" {
  name                 = "service-image"
  image_tag_mutability = "MUTABLE"

  image_scanning_configuration {
    scan_on_push = true
  }
}

References