{"id":21725444,"url":"https://github.com/jameswoolfenden/terraform-aws-ecr","last_synced_at":"2026-01-23T20:39:55.318Z","repository":{"id":81359193,"uuid":"164227247","full_name":"JamesWoolfenden/terraform-aws-ecr","owner":"JamesWoolfenden","description":"A terraform module to create a container registry (ECR - Elastic Container Registry) in AWS","archived":false,"fork":false,"pushed_at":"2024-09-06T12:02:32.000Z","size":130,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T11:46:06.891Z","etag":null,"topics":["aws","ecr","module","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamesWoolfenden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-05T15:30:58.000Z","updated_at":"2024-09-06T12:02:30.000Z","dependencies_parsed_at":"2025-01-25T19:36:12.455Z","dependency_job_id":null,"html_url":"https://github.com/JamesWoolfenden/terraform-aws-ecr","commit_stats":null,"previous_names":[],"tags_count":91,"template":false,"template_full_name":null,"purl":"pkg:github/JamesWoolfenden/terraform-aws-ecr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-ecr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-ecr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-ecr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-ecr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesWoolfenden","download_url":"https://codeload.github.com/JamesWoolfenden/terraform-aws-ecr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-ecr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28699694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","ecr","module","terraform"],"created_at":"2024-11-26T03:17:43.575Z","updated_at":"2026-01-23T20:39:55.312Z","avatar_url":"https://github.com/JamesWoolfenden.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform-aws-ecr\n\n[![Build Status](https://github.com/JamesWoolfenden/terraform-aws-ecr/workflows/Verify%20and%20Bump/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-aws-ecr)\n[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-aws-ecr.svg)](https://github.com/JamesWoolfenden/terraform-aws-ecr/releases/latest)\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/JamesWoolfenden/terraform-aws-ecr.svg?label=latest)](https://github.com/JamesWoolfenden/terraform-aws-ecr/releases/latest)\n![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.14.0-blue.svg)\n[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/JamesWoolfenden/terraform-aws-ecr/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github\u0026fullRepo=JamesWoolfenden%2Fterraform-aws-ecr\u0026benchmark=CIS+AWS+V1.2)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)\n[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-aws-ecr/general)](https://www.bridgecrew.cloud/link/badge?vcs=github\u0026fullRepo=JamesWoolfenden%2Fterraform-aws-ecr\u0026benchmark=INFRASTRUCTURE+SECURITY)\n\n---\n\nTerraform module to provision an AWS [`Elastic Container Registry`](https://aws.amazon.com/ecr/)\n\nThis registry is immutable, so you cannot push the \"latest\" container twice.\n\nIt's 100% Open Source and licensed under the [APACHE2](LICENSE).\n\n![alt text](./diagram/registry.png)\n\n## Usage\n\nInclude this repository as a module in your existing Terraform code:\n\n```terraform\nmodule ecr {\n  source           = \"github.com/JamesWoolfenden/terraform-aws-ecr\"\n  version          = \"v0.2.30\"\n  name             = var.name\n  repositorypolicy = data.aws_iam_policy_document.allowlocals.json\n}\n```\n\n## Costs\n\n```text\nMonthly cost estimate\n\nProject: .\n\n Name                                                   Monthly Qty  Unit            Monthly Cost\n\n module.ecs.aws_efs_file_system.examplea\n └─ Storage (standard)                                Cost depends on usage: $0.33 per GB-months\n\n module.ecs.aws_elb.admin\n ├─ Classic load balancer                                       730  hours                 $21.46\n └─ Data processed                                    Cost depends on usage: $0.0084 per GB\n\n module.ecs.aws_elb.appstore\n ├─ Classic load balancer                                       730  hours                 $21.46\n └─ Data processed                                    Cost depends on usage: $0.0084 per GB\n\n module.ecs.aws_instance.docker_host\n ├─ Instance usage (Linux/UNIX, on-demand, t3.micro)            730  hours                  $8.61\n ├─ EC2 detailed monitoring                                       7  metrics                $2.10\n ├─ CPU credits                                                   0  vCPU-hours             $0.00\n └─ root_block_device\n    ├─ Storage (magnetic)                                       100  GB-months              $5.80\n    └─ I/O requests                                   Cost depends on usage: $0.06 per 1M request\n\n PROJECT TOTAL                                                                             $59.44\n```\n\n### Logging-in to ECR\n\nFirst get your account number with:\n\n```shell\naws sts get-caller-identity\n```\n\nThen use that to login with:\n\n_aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin \u003caws_account_id\u003e.dkr.ecr.\u003cregion\u003e.amazonaws.com_\n\n```shell\naws ecr get-login-password --region eu-west-2 | docker login  --username AWS  --password-stdin 481212720429.dkr.ecr.eu-west-2.amazonaws.com\n```\n\nNow build your Dockerfile\n\n```Dockerfile\nFROM alpine:3.5\n```\n\n```shell\n$docker build .\n$docker images                               ✔ │ 4s │ 11:41:46 \nREPOSITORY   TAG       IMAGE ID       CREATED         SIZE\n\u003cnone\u003e       \u003cnone\u003e    bb8a493bc0a0   24 months ago   4MB\n```\n\nThen tag the image:\n\n```shell\ndocker tag bb8a493bc0a0  481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform\n```\n\nWARNING:This used the \"latest\" tag up and as this repo is immutable you cannot use it twice.\n\n```shell\ndocker push 481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform\ndocker push 481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform\nUsing default tag: latest\nThe push refers to repository [481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform]\nf566c57e6f2d: Pushed\n```\n\n## Update Docker file\n\nAdd this to the Dockerfile:\n\n```Dockerfile\nRUN apk add --update py2-pip\n```\n\nBuild it and get image - cce562ae9658\n\nTag it the same and try to push it:\n\n```shell\ndocker tag cce562ae9658  481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform\n\ndocker push 481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform\n\nThe push refers to repository [481212720429.dkr.ecr.eu-west-2.amazonaws.com/node-terraform]\n75867783c8d9: Pushed\nf566c57e6f2d: Layer already exists\ntag invalid: The image tag 'latest' already exists in the 'node-terraform' repository and cannot be overwritten because the repository is immutable.\n```\n\n\u003c!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n## Requirements\n\nNo requirements.\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | n/a |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_ecr_lifecycle_policy.cleanup](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_lifecycle_policy) | resource |\n| [aws_ecr_repository.repository](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository) | resource |\n| [aws_ecr_repository_policy.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository_policy) | resource |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_common_tags\"\u003e\u003c/a\u003e [common\\_tags](#input\\_common\\_tags) | Implements the common tags scheme | `map(any)` | n/a | yes |\n| \u003ca name=\"input_encryption_type\"\u003e\u003c/a\u003e [encryption\\_type](#input\\_encryption\\_type) | n/a | `string` | `\"KMS\"` | no |\n| \u003ca name=\"input_image_tag_mutability\"\u003e\u003c/a\u003e [image\\_tag\\_mutability](#input\\_image\\_tag\\_mutability) | For sone strange reason this is optional behaviour. | `string` | `\"IMMUTABLE\"` | no |\n| \u003ca name=\"input_kms_key\"\u003e\u003c/a\u003e [kms\\_key](#input\\_kms\\_key) | n/a | `string` | n/a | yes |\n| \u003ca name=\"input_name\"\u003e\u003c/a\u003e [name](#input\\_name) | The name of the registry | `string` | n/a | yes |\n| \u003ca name=\"input_repositorypolicy\"\u003e\u003c/a\u003e [repositorypolicy](#input\\_repositorypolicy) | Pass this variable a Json Policy | `string` | n/a | yes |\n| \u003ca name=\"input_scan_on_push\"\u003e\u003c/a\u003e [scan\\_on\\_push](#input\\_scan\\_on\\_push) | Security Scan your new container before you add it to the registry | `bool` | `true` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_ecr\"\u003e\u003c/a\u003e [ecr](#output\\_ecr) | The full details of the repo |\n| \u003ca name=\"output_ecr_arn\"\u003e\u003c/a\u003e [ecr\\_arn](#output\\_ecr\\_arn) | The Amazon resource name for the repository |\n| \u003ca name=\"output_ecr_repo_name\"\u003e\u003c/a\u003e [ecr\\_repo\\_name](#output\\_ecr\\_repo\\_name) | The name of the repository |\n| \u003ca name=\"output_ecr_repository_url\"\u003e\u003c/a\u003e [ecr\\_repository\\_url](#output\\_ecr\\_repository\\_url) | The URL of your new registry |\n\u003c!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n\n## Policy\n\nThis is the policy required to build this project:\n\n\u003c!-- BEGINNING OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\nThe Terraform resource required is:\n\n```golang\nresource \"aws_iam_policy\" \"terraform_pike\" {\n  name_prefix = \"terraform_pike\"\n  path        = \"/\"\n  description = \"Pike Autogenerated policy from IAC\"\n\n  policy = jsonencode({\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"VisualEditor0\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ec2:DescribeAccountAttributes\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"VisualEditor1\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ecr:CreateRepository\",\n                \"ecr:DeleteLifecyclePolicy\",\n                \"ecr:DeleteRepository\",\n                \"ecr:DeleteRepositoryPolicy\",\n                \"ecr:DescribeRepositories\",\n                \"ecr:GetLifecyclePolicy\",\n                \"ecr:GetRepositoryPolicy\",\n                \"ecr:ListTagsForResource\",\n                \"ecr:PutImageScanningConfiguration\",\n                \"ecr:PutLifecyclePolicy\",\n                \"ecr:SetRepositoryPolicy\",\n                \"ecr:TagResource\",\n                \"ecr:UntagResource\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"VisualEditor2\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"kms:CreateGrant\",\n                \"kms:DescribeKey\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n})\n}\n\n\n```\n\u003c!-- END OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\n\n## Information\n\nA terraform module to create a container registry (ECR - Elastic Container Registry) in AWS.\nThere are two policies attached, a life-cycle policy which details how to look after the containers and a permission policy which has a default allow allusers in the account.\nI use this to store the customised containers I use in Codebuild and for storing containers for Fargate.\n\n## Related Projects\n\nCheck out these related projects.\n\n- [terraform-aws-codebuild](https://github.com/jameswoolfenden/terraform-aws-codebuild) - Making a Build pipeline\n\n## Help\n\n**Got a question?**\n\nFile a GitHub [issue](https://github.com/jameswoolfenden/terraform-aws-ecr/issues).\n\n## Contributing\n\n### Bug Reports \u0026 Feature Requests\n\nPlease use the [issue tracker](https://github.com/jameswoolfenden/terraform-aws-ecr/issues) to report any bugs or file feature requests.\n\n## Copyrights\n\nCopyright © 2019-2022 James Woolfenden\n\n## License\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nSee [LICENSE](LICENSE) for full details.\n\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n\u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied. See the License for the\nspecific language governing permissions and limitations\nunder the License.\n\n### Contributors\n\n[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]\u003cbr/\u003e[James Woolfenden][jameswoolfenden_homepage]\n\n[jameswoolfenden_homepage]: https://github.com/jameswoolfenden\n[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-ecr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-ecr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-ecr/lists"}