AWS ECR

Amazon Elastic Container Registry (Amazon ECR) is a fully managed container registry offering high-performance hosting, so you can reliably deploy application images and artifacts anywhere.

This module creates AWS ECR with these possibilities :

  • Enable or disable mutability

  • Enable or disable the scan on push

  • Enable or disable the force delete

  • Choose the encryption type

  • Set ECR policy on only pull accounts and/or push and pull accounts

  • Set a lifecycle policy

This module must be used with these constraints:

  • Use the same availability zone to all the repositories

  • Give the image name and the tag of the all repositories

Requirements

Name

Version

terraform

>= 1.0

aws

>= 5.61

generic

>= 0.1.1

skopeo2

>= 1.1.1

Providers

Name

Version

aws

>= 5.61

generic

>= 0.1.1

skopeo2

>= 1.1.1

Modules

No modules.

Resources

Name

Type

aws_ecr_lifecycle_policy.ecr_lifecycle_policy

resource

aws_ecr_repository.ecr

resource

aws_ecr_repository_policy.policy

resource

generic_local_cmd.logout_public_ecr_login_private

resource

skopeo2_copy.copy_images

resource

aws_caller_identity.current

data source

aws_ecr_authorization_token.current

data source

aws_iam_policy_document.admin

data source

aws_iam_policy_document.only_pull

data source

aws_iam_policy_document.permissions

data source

aws_iam_policy_document.push_and_pull

data source

aws_region.current

data source

Inputs

Name

Description

Type

Default

Required

aws_profile

AWS Profile used to login and push container images on ECR

string

n/a

yes

encryption_type

The encryption type to use for the repository.

string

"AES256"

no

force_delete

If true, will delete the repository even if it contains images.

bool

true

no

kms_key_id

KMS to encrypt ECR repositories

string

null

no

lifecycle_policy

Manages an ECR repository lifecycle policy

map(any)

null

no

mutability

The tag mutability setting for the repository

string

"MUTABLE"

no

only_pull_accounts

List of accounts having pull permission

list(string)

[]

no

push_and_pull_accounts

List of accounts having push and pull permissions

list(string)

[]

no

repositories

Map of ECR repositories to create. Each repository is an object of “image” and “tag” parameters

map(object({
image = string
tag = string
}))

{}

no

scan_on_push

Indicates whether images are scanned after being pushed to the repository or not scanned

bool

null

no

tags

Tags for resource

any

{}

no

Outputs

Name

Description

kms_key_id

ARN of KMS used for ECR

repositories

Map of ECR repositories created on AWS

Examples