Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sterliakov/terraform-aws-ecr-image
https://github.com/sterliakov/terraform-aws-ecr-image
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sterliakov/terraform-aws-ecr-image
- Owner: sterliakov
- License: apache-2.0
- Created: 2024-11-03T17:04:57.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-03T19:39:56.000Z (2 months ago)
- Last Synced: 2024-11-03T20:32:07.744Z (2 months ago)
- Language: HCL
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Temporary ECR image
![AWS](https://img.shields.io/badge/AWS-%23FF9900.svg?style=for-the-badge&logo=amazon-aws&logoColor=white)
![Terraform](https://img.shields.io/badge/terraform-%235835CC.svg?style=for-the-badge&logo=terraform&logoColor=white)![License](https://badgen.net/github/license/sterliakov/terraform-aws-ecr-image/)
![Release](https://badgen.net/github/release/sterliakov/terraform-aws-ecr-image/)---
## PURPOSE
When AWS Lambda is deployed with container `image` source, that image must already
exist. This makes deployment of such a function with terraform complicated: first
`terraform apply` should create a ECR repository, then some other CI pipeline
should build and push an image, and only then a lambda can be created.This module streamlines this process by pushing some tiny image as a placeholder.
Idea and the initial code was borrowed from
[this StackOverflow answer](https://stackoverflow.com/a/78501527/14401160),
but the implementation was significantly rewritten.## USAGE
Push a dummy Alpine image to a newly created ECR repository:
```terraform
resource "aws_ecr_repository" "example" {
name = "example"
}module "ecr_repo_image" {
source = "sterliakov/ecr-image/aws"
version = "0.1.0"push_ecr_is_public = false
push_repo_fqdn = replace(aws_ecr_repository.example.repository_url, "//.*$/", "") # remove everything after first slash
push_repo_name = aws_ecr_repository.example.name
push_image_tag = "deployed"
}
```## NOTES
* This module only works under Linux.
* Destroying this module does not remove the pushed image from the repository. Consider
setting `force_delete = True` on the `aws_ecr_repository` resource if you
want to remove the repository with terraform later.
* This module needs `curl` and `jq` on `PATH`. If `jq` are missing, it will fetch
and install `jq 1.7.1` locally for the appropriate architecture.## EXAMPLES
- [Lambda](examples/lambda) - Deploy a dummy image for Lambda (5 MB alpine by default)
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [pull\_ecr\_is\_public](#input\_pull\_ecr\_is\_public) | If the ECR repo we're pulling from is public (vs. private) | `bool` | `true` | no |
| [pull\_image\_arch](#input\_pull\_image\_arch) | The arch of the image we're pulling, e.g. amd64 | `string` | `"amd64"` | no |
| [pull\_image\_tag](#input\_pull\_image\_tag) | The tag of the image we're pulling, e.g. latest | `string` | `"3.20.3"` | no |
| [pull\_repo\_fqdn](#input\_pull\_repo\_fqdn) | The FQDN of the ECR repo we're pulling from, e.g. public.ecr.aws | `string` | `"public.ecr.aws"` | no |
| [pull\_repo\_name](#input\_pull\_repo\_name) | The name of the ECR repo we're pulling from, e.g. my-repo | `string` | `"docker/library/alpine"` | no |
| [push\_ecr\_is\_public](#input\_push\_ecr\_is\_public) | If the ECR repo we're pushing to is public (vs. private) | `bool` | `false` | no |
| [push\_image\_tag](#input\_push\_image\_tag) | The tag of the image we're pushing, e.g. latest | `string` | n/a | yes |
| [push\_repo\_fqdn](#input\_push\_repo\_fqdn) | The FQDN of the ECR repo we're pushing to, e.g. 012345678910.dkr.ecr..amazonaws.com | `string` | n/a | yes |
| [push\_repo\_name](#input\_push\_repo\_name) | The name of the ECR repo we're pushing to, e.g. my-repo | `string` | n/a | yes |## Modules
No modules.
## Outputs
No outputs.
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 5.40.0 |
| [terraform](#provider\_terraform) | n/a |## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.7.0 |
| [aws](#requirement\_aws) | >= 5.40.0 |## Resources
| Name | Type |
|------|------|
| [terraform_data.ecr_repo_image](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
| [aws_ecrpublic_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecrpublic_authorization_token) | data source |## CONTRIBUTING
Contributions are very welcomed!
Start by reviewing [contribution guide](CONTRIBUTING.md) and our [code of conduct](CODE_OF_CONDUCT.md). After that, start coding and ship your changes by creating a new PR.
## LICENSE
Apache 2 Licensed. See [LICENSE](LICENSE) for full details.