Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

ppastorf
Copy link

@ppastorf ppastorf commented May 17, 2024

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.

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@ppastorf ppastorf changed the title Set var.create_lifecycle_policy default to false Fix case when Terraform breaks trying to create a Repository lifecycle policy with empty argument May 17, 2024
Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ppastorf
Copy link
Author

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.

Copy link

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 github-actions bot added the stale label Jun 17, 2024
Copy link

This PR was automatically closed because of stale in 10 days

@github-actions github-actions bot closed this Jun 28, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants