-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Cannot set null/undefined value for aws_s3_bucket lifecycle_rule expiration days #1544
Comments
Hi folks 👋 This issue is resolved in Terraform 0.12, which supports new functionality in the configuration language aimed at solving this issue. The new Since Given this configuration: variable "test1" {
type = list(object({
date = string
days = number
}))
default = [{
date = "2020-01-01"
days = null
}]
}
variable "test2" {
type = list(object({
date = string
days = number
}))
default = [{
date = null
days = 10
}]
}
resource "aws_s3_bucket" "test1" {
bucket = "tf-test1-1544"
lifecycle_rule {
enabled = true
id = "test"
prefix = "test/"
dynamic "expiration" {
for_each = var.test1
content {
date = expiration.value.date
days = expiration.value.days
}
}
}
}
resource "aws_s3_bucket" "test2" {
bucket = "tf-test2-1544"
lifecycle_rule {
enabled = true
id = "test"
prefix = "test/"
dynamic "expiration" {
for_each = var.test2
content {
date = expiration.value.date
days = expiration.value.days
}
}
}
} Produces the following apply output:
Enjoy! 🚀 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Terraform Version
v0.10.2
Affected Resource(s)
Terraform Configuration Files
Debug Output
https://gist.github.com/kevinchn/49d5a846acc822e630f1bc8479508be9
Panic Output
Expected Behavior
Since Terraform doesn't support a null/undefined value, resources should accept a "zero" value as unset according to this comment by mitchellh
This is necessary when expiration days is a variable.
The previous behavior on v.0.9.11 is that an empty lifecycle rule was created (without any expirations)
Actual Behavior
A Terraform validation error is thrown
Setting days = "" also doesn't work (with error:
cannot parse '' as int: strconv.ParseInt: parsing "": invalid syntax
)Steps to Reproduce
terraform init
andterraform apply
Important Factoids
We did not get this error on v.0.9.11.
References
hashicorp/terraform#5471 (comment)
It appears this validation was added in the PR #957
The text was updated successfully, but these errors were encountered: