Lesson 3 of 6 Container Platforms and Microservices

Managing Container Images Securely with Amazon ECR

This lesson explains how Amazon ECR scans images, controls their lifecycle, keeps tags immutable, replicates images and supports signing.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish basic and enhanced scanning in ECR.
  • Explain how lifecycle policies, tag immutability and replication support cost, integrity and DR.
  • Identify the controls that ensure only trusted images are deployed.

Scanning for vulnerabilities

ECR basic scanning checks operating system packages when an image is pushed or on demand. Enhanced scanning uses Amazon Inspector to scan operating system and programming language packages continuously and to re-evaluate stored images when new CVEs are published; findings appear in Inspector and Security Hub and are sent to EventBridge, where they can notify owners or block deployment. Registry-level scanning rules apply the configuration to repositories by name filter, so new repositories are covered automatically.

Lifecycle, immutability and replication

Lifecycle policies expire images by rules evaluated in priority order, for example deleting untagged images after seven days and keeping only the most recent 50 images with a release- tag prefix, which controls storage cost from CI builds. Tag immutability rejects a push that would reuse an existing tag, so a release tag always refers to the image that was tested (deploying by image digest gives the same guarantee). Replication copies images to other Regions and accounts, which puts images close to clusters and keeps them available for disaster recovery.

The following diagram shows a central registry serving many accounts and Regions.

A central container image registry. A pipeline in a tools account pushes images to Amazon ECR, where tag immutability prevents tags being reused, enhanced scanning with Amazon Inspector checks every image continuously, and lifecycle policies expire old builds. Replication copies images to other Regions, and a registry policy lets every account in the organisation pull them.
Push access stays with the pipeline; everyone else in the organisation can only pull.
Match the pairs

ECR features

Exam skills 1.1.8

Match each requirement with the ECR feature that meets it.

Log in to try this activity Interactive activities are free with an account.

Access and signing

Repository and registry policies grant pull access to other accounts, for example to the whole organisation with aws:PrincipalOrgID, while push access stays with the pipeline. Images can be signed, with AWS Signer and the Notation client or with ECR managed signing, and clusters verify signatures before running them, so only images built by the trusted pipeline are deployed. Pull-through cache rules keep copies of public images in ECR so builds do not depend on external registries.

The following table maps image management needs to ECR features.

NeedECR feature
Find vulnerabilities, including in language packages, continuouslyEnhanced scanning (Amazon Inspector)
Control storage of old and untagged imagesLifecycle policy
Guarantee a tag always means the tested imageTag immutability, or deploy by digest
Images available in other Regions and accountsReplication rules
Run only images from the trusted pipelineImage signing with verification at deployment
Worked example

A central image registry

A platform team builds base images and application images for 60 accounts in three Regions, and auditors require that no image with a critical vulnerability is deployed.

Images are built in a tools account and pushed to ECR with tag immutability; a registry policy allows pulls from the organisation, and replication rules copy release repositories to the other two Regions.

Enhanced scanning runs continuously; an EventBridge rule notifies the owning team of new critical findings, and the pipeline's deploy stage checks findings for the image digest before promotion. A lifecycle policy deletes untagged images after seven days, which removed most of the registry's storage cost.

Check yourself

Basic scanning found no issues when an image was pushed six months ago. Is the image still safe?

Show answer

Not necessarily. Basic scanning runs on push or on demand, so newly published CVEs are not detected. Enhanced scanning re-evaluates stored images continuously.

Exam Tips

Remember for the exam

  • Continuous scanning of OS and language packages: ECR enhanced scanning with Amazon Inspector.
  • Old and untagged images increase cost: lifecycle policy.
  • Production must run exactly the tested image: tag immutability or deploy by digest.
  • Images needed in another Region for DR: ECR replication.