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

[Bug]: aws_s3_bucket_lifecycle_configuration with filter object_size_greater_than = "0" doesn't work #28851

Closed
ade028 opened this issue Jan 12, 2023 · 7 comments · Fixed by #29857
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@ade028
Copy link

ade028 commented Jan 12, 2023

Terraform Core Version

1.3.7

AWS Provider Version

4.49.0

Affected Resource(s)

aws_s3_bucket_lifecycle_configuration
=> filter object_size_greater_than

Expected Behavior

object_size_greater_than = "0"
Terraform apply completes successfully and changes in the AWS console visible.
A reapply doesn't show any change.

Actual Behavior

object_size_greater_than = "0"
Terraform apply completes successfully but no change in the AWS console visible.
A reapply shows the same change as not executed in AWS.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_s3_bucket_lifecycle_configuration" "logs_sse_s3_exceptions" {
  bucket = aws_s3_bucket.logs_sse_s3_exceptions.id

  rule {
    id     = "Lifecycle"
    status = "Enabled"

    filter {
      object_size_greater_than = "0"
    }

    expiration {
      days = 14
    }

    noncurrent_version_expiration {
      noncurrent_days = 14
    }
  }
}

Steps to Reproduce

object_size_greater_than = "0" in filter of lifecycle configuration rule.
Terraform apply completes successfully but no change in the AWS console visible.
A reapply shows the same change as not executed in AWS.
No object_size_greater_than in the API call :
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><Filter><Prefix></Prefix></Filter><ID>Lifecycle</ID><NoncurrentVersionExpiration><NoncurrentDays>14</NoncurrentDays></NoncurrentVersionExpiration><Status>Enabled</Status><Expiration><Days>14</Days></Expiration></Rule></LifecycleConfiguration>

object_size_greater_than = "1"
Terraform apply completes successfully and change in the AWS console visible.
A reapply doesn't show any change.
object_size_greater_than in API call :
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><Expiration><Days>14</Days></Expiration><Filter><ObjectSizeGreaterThan>1</ObjectSizeGreaterThan></Filter><ID>Lifecycle</ID><NoncurrentVersionExpiration><NoncurrentDays>14</NoncurrentDays></NoncurrentVersionExpiration><Status>Enabled</Status></Rule></LifecycleConfiguration>

Debug Output

2023-01-12T17:02:29.125+0100 [DEBUG] provider.terraform-provider-aws_v4.49.0_x5: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>Lifecycle</ID><Filter><Prefix></Prefix></Filter><Status>Enabled</Status><Expiration><Days>14</Days></Expiration><NoncurrentVersionExpiration><NoncurrentDays>14</NoncurrentDays></NoncurrentVersionExpiration></Rule></LifecycleConfiguration>
2023-01-12T17:02:29.127+0100 [WARN]  Provider "provider[\"registry.terraform.io/hashicorp/aws\"].dev" produced an unexpected new value for module.dev_account.aws_s3_bucket_lifecycle_configuration.logs_sse_s3_exceptions, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .rule[0].filter[0].object_size_greater_than: was cty.StringVal("0"), but now cty.StringVal("")
2023-01-12T17:02:29.134+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-01-12T17:02:29.144+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/4.49.0/darwin_amd64/terraform-provider-aws_v4.49.0_x5 pid=89873
2023-01-12T17:02:29.145+0100 [DEBUG] provider: plugin exited

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@ade028 ade028 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jan 12, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/s3 Issues and PRs that pertain to the s3 service. label Jan 12, 2023
@ade028
Copy link
Author

ade028 commented Jan 13, 2023

Looking at the documentation, it has to be specified as an int but even, it's not working.
This is the API call when passing 0 instead of "0"
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><Expiration><Days>14</Days></Expiration><Filter><Prefix></Prefix></Filter><ID>Lifecycle</ID><NoncurrentVersionExpiration><NoncurrentDays>14</NoncurrentDays></NoncurrentVersionExpiration><Status>Enabled</Status></Rule></LifecycleConfiguration>

@ade028
Copy link
Author

ade028 commented Jan 17, 2023

Hi,
If I filter on prefix and the object size greater than "0" with the "and", I get a malformed XML error as block is alone inside the block. If I specify a size of "1", it's updated successfully.
Could it be linked to that change?
#23441 and by consequence "0" (which is an allowed value in console) is considered as null ?
Thanks!

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jan 17, 2023
@ade028
Copy link
Author

ade028 commented Feb 3, 2023

Anybody having same issue?

@ade028
Copy link
Author

ade028 commented Mar 10, 2023

I have tested the fix proposed by @pvbouwel. It works actually and solve my issue.
The apply finish successfully and when I run a new plan after the apply, there is no more changes.
And when checking inside of the console, I see the lifecycle rule updated.
Thanks!

@github-actions github-actions bot added this to the v4.62.0 milestone Mar 31, 2023
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

This functionality has been released in v4.62.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented May 8, 2023

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 have found a problem that seems similar to this, 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 May 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants