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

Lifcycle Rules enforce mutually exclusive defaults #87

Closed
Moncky opened this issue May 17, 2021 · 4 comments · Fixed by #135
Closed

Lifcycle Rules enforce mutually exclusive defaults #87

Moncky opened this issue May 17, 2021 · 4 comments · Fixed by #135
Labels
bug 🐛 An issue with the system

Comments

@Moncky
Copy link

Moncky commented May 17, 2021

Describe the Bug

The lifecycle rule blocks intoduced in 0.35.0 enforces mutually exclusive defaults when enabled.
When enabled each of the options need to be declared when calling the module.

When you run with a fully declared lifecycle_rules your get this error

│ Error: Error putting S3 lifecycle: InvalidRequest: AbortIncompleteMultipartUpload cannot be specified with Tags.

If you remove the tags option you get:

│ The given value is not suitable for child module variable "lifecycle_rules"
│ defined at .terraform/modules/s3_bucket/variables.tf:82,1-27: element 0:
│ attribute "tags" is required.

If you leave tags and remove abort_incomplete_multipart_upload_days:

│ The given value is not suitable for child module variable "lifecycle_rules"
│ defined at .terraform/modules/s3_bucket/variables.tf:82,1-27: element 0:
│ attribute "abort_incomplete_multipart_upload_days" is required.

Expected Behavior

  1. When I choose to enable and populate lifecycle_rules = [] the life cycle rules should require mutually exclusive options.
  2. When I choose to enable and populate lifecycle_rules = [] I should only need to define the acutal paramters I want to modify from the defaults.

I should only need to do:

  lifecycle_rules = [
    {
      standard_transition_days = 30
      glacier_transition_days = 120
      expiration_days = 365
    }]

rather than

lifecycle_rules = [{
   enabled = false
   prefix  = ""
   tags    = {}

   enable_glacier_transition        = true
   enable_deeparchive_transition    = false
   enable_standard_ia_transition    = false
   enable_current_object_expiration = true

   abort_incomplete_multipart_upload_days         = 90
   noncurrent_version_glacier_transition_days     = 30
   noncurrent_version_deeparchive_transition_days = 60
   noncurrent_version_expiration_days             = 90

   standard_transition_days    = 30
   glacier_transition_days     = 120
   deeparchive_transition_days = 90
   expiration_days             = 365
 }]

Steps to Reproduce

Steps to reproduce the behavior:
Define a lifecycle rule as per the long example given above. You will get an error advising tags and abort_incomplete_multipart_upload_days can not both be defined. Adress that error either way and try and run again. You will get an error saying each element is required.

Environment (please complete the following information):

Terraform v0.15.3
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v3.39.0
@Moncky Moncky added the bug 🐛 An issue with the system label May 17, 2021
@Moncky
Copy link
Author

Moncky commented May 17, 2021

I've had a look at this to see if I could get a work round. It looks like this is something that is going to be addressed when the defaults funciton is finally added https://www.terraform.io/docs/language/functions/defaults.html

In the meantime, the only way I could get this to work at all, was to remove the default list and replace it with

variable "lifecycle_rules" {
  default = []
  description = "A list of lifecycle rules"
}

Happy to sort out a PR for the above if there isn't some other trick that can be done with dynamic blocks that I'm not aware of.

@nitrocode
Copy link
Member

Yes, were waiting on the ability to make keys optional.

We want the default lifecycle list. You could override the default by setting an empty list for that input variable when calling the module.

@honcharenkoy90
Copy link

Hi, any ideas when this issue will be resolved?

@nitrocode
Copy link
Member

@honcharenkoy90

You could override the default by setting an empty list for that input variable when calling the module.

Have you tried this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants