ECR repository without a customer managed KMS key

Choose ECR encryption settings that meet key-management requirements.

Description

ECR encrypts images with S3-managed keys by default. Setting only EncryptionType: KMS selects an AWS managed key.

Potential impact

If your organization requires its own key policy or key audit controls, specify a customer managed key.

Remediation

At creation, set EncryptionType: KMS and a customer managed KmsKey from the same Region under EncryptionConfiguration. Changing an existing repository’s encryption configuration requires replacement.

Examples

Both examples use the same logical ID and repository name, test-repository. Keep the original and add a repository with a different name and logical ID. Copy the images and test a pull as the deployment role before switching deployment references.

Before

json
{
  "Resources": {
    "MyRepository": {
      "Type": "AWS::ECR::Repository",
      "Properties": {
        "RepositoryName": "test-repository"
      }
    }
  }
}

After

json
{
  "Resources": {
    "MyRepository": {
      "Type": "AWS::ECR::Repository",
      "Properties": {
        "RepositoryName": "test-repository",
        "EncryptionConfiguration": {
          "EncryptionType": "KMS",
          "KmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
        }
      }
    }
  }
}

References