terraform-aws-modules / terraform-aws-ecr

Terraform module to create AWS ECR resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/ecr/aws
Apache License 2.0
52 stars 109 forks source link

Fix case when Terraform breaks trying to create a Repository lifecycle policy with empty argument #42

Closed ppastorf closed 2 months ago

ppastorf commented 4 months ago

Description

This is a very simple PR to change the default of "create_lifecycle_policy" variable to false avoid breaking during apply phase when both var.create_lifecycle_policy and var.repository_lifecycle_policy are left unset.

Motivation and Context

If left unset both var.create_lifecycle_policy and var.repository_lifecycle_policy, Terraform will try to create the policy but using a empty string as argument, leading to the following error:

Error: creating ECR Lifecycle Policy (sos-rs-freetier-backend): operation error ECR: PutLifecyclePolicy, https response error StatusCode: 400, RequestID: c560fdf2-529f-4e79-837f-6ddf72eaed08, InvalidParameterException: Invalid parameter at 'lifecyclePolicyText' failed to satisfy constraint: 'Member must have length greater than or equal to 100'
│
│   with aws_ecr_lifecycle_policy.this[0],
│   on main.tf line 213, in resource "aws_ecr_lifecycle_policy" "this":
│  213: resource "aws_ecr_lifecycle_policy" "this" {
│

Breaking Changes

There should be none.

How Has This Been Tested?

I have tested locally with Terragrunt. It should work.

ppastorf commented 4 months ago

If you don't want a lifecycle policy, then turn it off, no?

If both variables are left unset (default values) the module fails to apply because the default is to create an policy, but the default value for the policy is "". IMO this creates additional headache to the final user who just wants to quickly use the module.

github-actions[bot] commented 3 months ago

This PR has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this PR will be closed in 10 days

github-actions[bot] commented 2 months ago

This PR was automatically closed because of stale in 10 days

github-actions[bot] commented 1 month ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.