Skip to content

geekcell/terraform-aws-ecr-repository

Repository files navigation

Geek Cell GmbH

Code Quality

License GitHub release (latest tag) Release Validate Lint Test

Security

Infrastructure Tests

Cloud

Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests

Container

Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests

Data protection

Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests Infrastructure Tests

Terraform AWS ECR Repository

Are you looking for an efficient way to manage your Docker images in AWS? Look no further! Our team has extensive experience working with AWS ECS and has optimized this Terraform module for AWS Elastic Container Registry (ECR) that includes a lifecycle policy.

This module makes it easy to set up and manage your ECR repositories, as well as automatically delete images that are older than 30 days, saving you storage space and reducing your costs. The lifecycle policy ensures that your repositories are clean and up-to-date, freeing up resources and improving the performance of your application.

Our team has optimized this Terraform module to provide a seamless experience for users. Whether you are just getting started with containers or looking to enhance your current setup, this module provides a preconfigured solution for efficiently managing your ECS Cluster with enabled Container Insights, logging, and advanced monitoring.

With this Terraform module, you can quickly set up and manage your ECR repositories, and take advantage of the benefits of a lifecycle policy, all with just a few simple commands. Try it out today!

Inputs

Name Description Type Default Required
force_delete Delete the repository even if it contains images. bool false no
image_tag_mutability The tag mutability setting for the repository. string "MUTABLE" no
lifecycle_rules Lifecycle policy rules for expiring images.
list(object({
description = optional(string)
tag_status = optional(string)
tag_prefix_list = optional(list(string))
count_type = string
count_unit = optional(string)
count_number = number
}))
[
{
"count_number": 30,
"count_type": "imageCountMoreThan",
"description": "Keep the last 30 tagged images",
"tag_prefix_list": [
"sha"
],
"tag_status": "tagged"
},
{
"count_number": 10,
"count_type": "sinceImagePushed",
"count_unit": "days",
"description": "Expire untagged images older than 10 days",
"tag_status": "untagged"
}
]
no
name Name of the ECR repository. string n/a yes
policy Repository policy document in JSON format. string null no
scan_on_push Indicates whether images are scanned after being pushed to the repository. bool true no
tags Tags to add to the ECR repository. map(any) {} no

Outputs

Name Description
arn The ARN of the repository.
name The name of the repository.
url The URL of the repository (in the form aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName).

Providers

Name Version
aws >= 4.36
jq 0.2.1

Resources

  • resource.aws_ecr_lifecycle_policy.main (main.tf#38)
  • resource.aws_ecr_repository.main (main.tf#19)
  • resource.aws_ecr_repository_policy.main (main.tf#31)
  • data source.jq_query.main (main.tf#47)

Examples

Full

module "basic_example" {
  source = "../../"

  name = var.name
}