Skip to content

adsanz-atalanta/terraform-aws-ecr

 
 

Repository files navigation

AWS ECR(s) Terraform module

Terraform module which creates AWS ECR resources in bulk.

Amazon Elastic Container Registry. Share and deploy container software, publicly or privately


Maintenance GitHub forks


Documentation

Usage example

IMPORTANT: The master branch is used in source just as an example. In your code, do not pin to master because there may be breaking changes between releases. Instead pin to the release tag (e.g. ?ref=tags/x.y.z) of one of our latest releases.

See examples directory for working examples to reference:

module "blueprint" {
  source  = "terraform-module/ecr/aws"
  version = "~> 1.0"

  ecrs = {
    api = {
      tags = { Service = "api" }
      lifecycle_policy = {
        rules = [{
          rulePriority = 1
          description  = "keep last 50 images"
          action = {
            type = "expire"
          }
          selection = {
            tagStatus   = "any"
            countType   = "imageCountMoreThan"
            countNumber = 50
          }
        }]
      }
    }
  }
}

Push docker image to repository

export ECR_REPO=AWS_ACCOUNT_ID.dkr.ecr.<REGION>.amazonaws.com/repositoryName
aws ecr get-login-password --region <REGION> | docker login --username AWS --password-stdin $ECR_REPO
docker pull cloudkats/hello-world-rest:latest
docker tag cloudkats/hello-world-rest:latest $ECR_REPO/api:latest
docker push $ECR_REPO/api:latest

Examples

See examples directory for working examples to reference

Assumptions

Available features

  • Create multiple ECR repositories
  • Manages an ECR repository lifecycle policy.

Requirements

Name Version
terraform >= 1

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_ecr_lifecycle_policy.this resource
aws_ecr_repository.this resource

Inputs

Name Description Type Default Required
ecrs Map of ECRs to create. any {} no
tags A mapping of tags to assign to all resources map(string) {} no

Outputs

Name Description
repositories Provides an Elastic Container Registry Repositories.
urls The URL of the repository (in the form aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName).

📝 Guidelines

  • 📝 Use a succinct title and description.
  • 🐛 Bugs & feature requests can be be opened
  • 📶 Support questions are better asked on Stack Overflow
  • 😊 Be nice, civil and polite (as always).

License

Copyright 2019 Ivan Katliarhcuk

MIT Licensed. See LICENSE for full details.

How to Contribute

Submit a pull request

Authors

Currently maintained by Ivan Katliarchuk and these awesome contributors.

ForTheBadge uses-git

Terraform Registry

Resources

About

ℹ️ Terraform module which creates AWS ECR resources.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 82.7%
  • Makefile 17.3%