-
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
r/s3_bucket_lifecycle_configuration: Provider produced inconsistent final plan #23883
Comments
Hi @Nuru , I've tried reproducing this error on update of the The example i've tried so far only hits the
resource "aws_s3_bucket" "this" {
bucket = "tf-test-abc-20220317"
}
locals {
lc_rules = [
{
abort_incomplete_multipart_upload_days = 1
enabled = true
expiration = {
days = null
expired_object_delete_marker = null
}
filter_prefix_only = {
prefix = "prefix1"
}
filter_and = null
id = "prefix1"
noncurrent_version_expiration = {
newer_noncurrent_versions = 2
noncurrent_days = 30
}
noncurrent_version_transition = []
transition = [
{
days = 7
storage_class = "GLACIER"
},
]
},
{
abort_incomplete_multipart_upload_days = 1
enabled = true
expiration = {
days = 93
expired_object_delete_marker = false
}
filter_prefix_only = null
filter_and = {
prefix = "prefix2"
object_size_greater_than = 131072
}
id = "prefix2"
noncurrent_version_expiration = {
newer_noncurrent_versions = 2
noncurrent_days = 14
}
noncurrent_version_transition = []
transition = [
{
days = 3
storage_class = "GLACIER"
},
]
}
]
}
resource "aws_s3_bucket_lifecycle_configuration" "default" {
bucket = aws_s3_bucket.this.id
dynamic "rule" {
for_each = local.lc_rules
content {
id = rule.value.id
status = rule.value.enabled == true ? "Enabled" : "Disabled"
expiration {
days = 90
}
# Filter is always required due to https://github.com/hashicorp/terraform-provider-aws/issues/23299
dynamic "filter" {
for_each = rule.value.filter_prefix_only == null && rule.value.filter_and == null ? ["empty"] : []
content {}
}
dynamic "filter" {
for_each = rule.value.filter_prefix_only == null ? [] : ["prefix"]
content {
prefix = rule.value.filter_prefix_only.prefix
}
}
dynamic "filter" {
for_each = rule.value.filter_and == null ? [] : ["and"]
content {
and {
object_size_greater_than = try(rule.value.filter_and.object_size_greater_than, null)
object_size_less_than = try(rule.value.filter_and.object_size_less_than, null)
prefix = rule.value.filter_and.prefix
tags = try(rule.value.filter_and.tags, null)
}
}
}
}
}
}
lc_rules = [
{
abort_incomplete_multipart_upload_days = 1
enabled = true
expiration = {
days = null
expired_object_delete_marker = null
}
filter_prefix_only = null
filter_and = null
id = "nofilter"
noncurrent_version_expiration = {
newer_noncurrent_versions = 2
noncurrent_days = 30
}
noncurrent_version_transition = []
transition = [
{
days = 7
storage_class = "GLACIER"
},
]
},
{
abort_incomplete_multipart_upload_days = 1
enabled = true
expiration = {
days = 93
expired_object_delete_marker = false
}
filter_prefix_only = {
prefix = "prefix1"
}
filter_and = null
id = "prefix1"
noncurrent_version_expiration = {
newer_noncurrent_versions = 2
noncurrent_days = 14
}
noncurrent_version_transition = []
transition = [
{
days = 3
storage_class = "GLACIER"
},
]
}
]
} which produced a similar update: Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# aws_s3_bucket_lifecycle_configuration.default will be updated in-place
~ resource "aws_s3_bucket_lifecycle_configuration" "default" {
id = "tf-test-abc-20220317"
# (1 unchanged attribute hidden)
~ rule {
~ id = "prefix1" -> "nofilter"
# (1 unchanged attribute hidden)
~ filter {
- prefix = "prefix1" -> null
}
# (1 unchanged block hidden)
}
~ rule {
~ id = "prefix2" -> "prefix1"
# (1 unchanged attribute hidden)
~ filter {
+ prefix = "prefix1"
~ and {
- object_size_greater_than = 131072 -> null
- prefix = "prefix2" -> null
tags = {}
# (1 unchanged attribute hidden)
}
}
# (1 unchanged block hidden)
}
}
|
@anGie44 I updated the issue description with a complete configuration. Note that in my testing, the first time I try to run with |
Thanks @Nuru , I'm able to reproduce with those set of instructions. Good news is that if I build the provider with the fix in #23893, I don't hit the |
I can no longer reproduce this bug now that v4.10.0 is out. Probably fixed in v4.9.0. Thank you. |
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. |
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v1.1.6
on darwin_amd64
Affected Resource(s)
Terraform Configuration Files
main.tf (click to reveal)
The issue appears to be that when the new list of rules doesn't line up with the old list of rules, and a rule goes from having
to
the provider gets confused.
Debug Output
Debug output contains sensitive information like API keys. How do I redact it?
Terraform `plan` output
Actual Behavior
On
terraform apply
Note that the same error message repeats but with
object_size_less_than
andprefix
attributes.Steps to Reproduce
terraform init
terraform apply -auto-approve
terraform apply -auto-approve -var trigger=true
# Triggers r/s3_bucket_lifecycle_configuration: Rule change generates MalformedXML #23884 MalformedXML, fails with errorterraform apply -auto-approve -var trigger=true
# Triggers this issueReferences
This complex setup of the
filter
configuration is made necessary by:The text was updated successfully, but these errors were encountered: