Skip to content

A Terraform module for creating a cross-account-accessible ECR repository.

License

Notifications You must be signed in to change notification settings

nsbno/terraform-aws-ecr

 
 

Repository files navigation

ECR Module

Creates a repository on ECR (and associated policies) that other accounts can be given push and pull access to.

  • Creates a repository on ECR

  • Creates a policy to allow other accounts push and pull access

  • Creates a lifecycle policy that expires images as follows:

    1. Retain only X untagged images (configurable, default is 1). This rule in itself should stop most issues.

    2. For each Element in the new variable protected_image_tag_prefixes (defaults to an empty list), retain only Y (configurable, default is 1) images whose tag starts with each of the elements of protected_image_tag_prefixes

    3. Retain only Z images in total (configurable, default is 100).

  • Enable/Disable vulnerability scan on image push (default enabled)

Usage

Remember to check out the variables and outputs to see all options.

module "ecr" {
  source      = "github.com/nsbno/terraform-aws-ecr?ref=x.y.z"
  repo_name   = "ecr-repo-example-name"

  trusted_accounts = [
    data.aws_caller_identity.current.account_id
  ]
}

Examples

See the basic example to see how to use this module

About

A Terraform module for creating a cross-account-accessible ECR repository.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • HCL 73.7%
  • Go 26.3%