https://github.com/tmknom/terraform-aws-ecr
Terraform module which creates ECR resources on AWS.
https://github.com/tmknom/terraform-aws-ecr
aws ecr terraform terraform-module
Last synced: 26 days ago
JSON representation
Terraform module which creates ECR resources on AWS.
- Host: GitHub
- URL: https://github.com/tmknom/terraform-aws-ecr
- Owner: tmknom
- License: apache-2.0
- Created: 2018-11-22T16:37:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-22T11:37:34.000Z (over 4 years ago)
- Last Synced: 2023-08-15T19:38:05.787Z (about 2 years ago)
- Topics: aws, ecr, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 54.7 KB
- Stars: 10
- Watchers: 3
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-aws-ecr
[](https://github.com/tmknom/terraform-aws-ecr/actions?query=workflow%3ATerraform)
[](https://github.com/tmknom/terraform-aws-ecr/actions?query=workflow%3AMarkdown)
[](https://github.com/tmknom/terraform-aws-ecr/actions?query=workflow%3AYAML)
[](https://github.com/tmknom/terraform-aws-ecr/actions?query=workflow%3AJSON)
[](https://registry.terraform.io/modules/tmknom/ecr/aws)
[](https://opensource.org/licenses/Apache-2.0)Terraform module which creates ECR resources on AWS.
## Description
Provision [ECR Repository](https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html),
[Repository Policy](https://docs.aws.amazon.com/AmazonECR/latest/userguide/RepositoryPolicies.html) and
[Lifecycle Policy](https://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html).This module provides recommended settings:
- Enable cross account access
- Automation of cleaning up unused images## Usage
### Minimal
```hcl
module "ecr" {
source = "git::https://github.com/tmknom/terraform-aws-ecr.git?ref=tags/2.3.0"
name = "minimal"
tag_prefix_list = ["release"]
}
```### Complete
```hcl
module "ecr" {
source = "git::https://github.com/tmknom/terraform-aws-ecr.git?ref=tags/2.3.0"
name = "complete"
tag_prefix_list = ["release"]
scan_on_push = true
image_tag_mutability = "IMMUTABLE"only_pull_accounts = ["123456789012"]
push_and_pull_accounts = ["111111111111"]
max_untagged_image_count = 5
max_tagged_image_count = 50
}
```## Examples
- [Minimal](https://github.com/tmknom/terraform-aws-ecr/tree/master/examples/minimal)
- [Complete](https://github.com/tmknom/terraform-aws-ecr/tree/master/examples/complete)## Requirements
| Name | Version |
| --------- | ------- |
| terraform | >= 0.12 |## Providers
| Name | Version |
| ---- | ------- |
| aws | n/a |## Inputs
| Name | Description | Type | Default | Required |
| ------------------------ | ---------------------------------------------------------------------------- | -------------- | ----------- | :------: |
| name | Name of the repository. | `string` | n/a | yes |
| tag_prefix_list | List of image tag prefixes on which to take action with lifecycle policy. | `list(string)` | n/a | yes |
| image_tag_mutability | Whether images are allowed to overwrite existing tags. | `string` | `"MUTABLE"` | no |
| max_tagged_image_count | The maximum number of tagged images that you want to retain in repository. | `number` | `30` | no |
| max_untagged_image_count | The maximum number of untagged images that you want to retain in repository. | `number` | `1` | no |
| only_pull_accounts | AWS accounts which pull only. | `list(string)` | `[]` | no |
| push_and_pull_accounts | AWS accounts which push and pull. | `list(string)` | `[]` | no |
| scan_on_push | Whether images should automatically be scanned on push or not. | `bool` | `false` | no |## Outputs
| Name | Description |
| -------------------------- | -------------------------------------------------------------------------------------------------- |
| ecr_repository_arn | Full ARN of the repository. |
| ecr_repository_name | The name of the repository. |
| ecr_repository_registry_id | The registry ID where the repository was created. |
| ecr_repository_url | The URL of the repository (in the form aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName) |## Development
### Development Requirements
- [Docker](https://www.docker.com/)
### Configure environment variables
```shell
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_DEFAULT_REGION=ap-northeast-1
```### Installation
```shell
git clone git@github.com:tmknom/terraform-aws-ecr.git
cd terraform-aws-ecr
make install
```### Makefile targets
```text
apply-complete Run terraform apply examples/complete
apply-minimal Run terraform apply examples/minimal
bump-version Bump version (Required argument 'VERSION')
check-format Check format code
clean Clean .terraform
destroy-complete Run terraform destroy examples/complete
destroy-minimal Run terraform destroy examples/minimal
diff Word diff
docs Generate docs
format Format code
help Show help
install Install requirements
lint Lint code
plan-complete Run terraform plan examples/complete
plan-minimal Run terraform plan examples/minimal
release Release GitHub and Terraform Module Registry
upgrade Upgrade makefile
```### Releasing new versions
Bump VERSION file, and run `make release`.
### Terraform Module Registry
-
## License
Apache 2 Licensed. See LICENSE for full details.