Skip to content

r/aws_s3_bucket_lifecycle_configuration: preserve transition_default_minimum_object_size when backend omits it - #49902

Open
kayrus wants to merge 1 commit into
hashicorp:mainfrom
kayrus:b-s3-lifecycle-transition-min-size-empty
Open

r/aws_s3_bucket_lifecycle_configuration: preserve transition_default_minimum_object_size when backend omits it#49902
kayrus wants to merge 1 commit into
hashicorp:mainfrom
kayrus:b-s3-lifecycle-transition-min-size-empty

Conversation

@kayrus

@kayrus kayrus commented Sep 8, 2026

Copy link
Copy Markdown

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

No. This change does not alter any access controls, encryption, or logging behavior.

Description

aws_s3_bucket_lifecycle_configuration never stabilized on S3-compatible
backends (e.g. Ceph RADOS Gateway), timing out during create/update.

The resource waits for the applied configuration to be readable back before
returning. That comparison includes transition_default_minimum_object_size,
which the provider defaults to 128k for general purpose buckets. AWS S3
always returns the corresponding x-amz-transition-default-minimum-object-size
field on GetBucketLifecycleConfiguration, but the field is optional and
S3-compatible backends omit it. The observed value therefore came back empty
and never matched the requested 128k, so the stabilization wait
(waitLifecycleConfigEquals) could never reach its target and timed out.
The empty value flattened into state also produced "inconsistent result after
apply" errors and perpetual diffs.

This change:

  • Tolerates an empty observed value in lifecycleConfigEqual, so the
    stabilization wait converges when the backend omits the field. The check is
    asymmetric by design — an empty observed value matches any requested value,
    but a non-empty observed value must still match exactly.
  • Preserves the planned (Create/Update) or prior (Read) value for
    transition_default_minimum_object_size when the flattened value is empty,
    avoiding the inconsistent-result error and perpetual diff.

On real AWS S3 both behaviors are strict no-ops, because AWS always populates
the field: the observed value is never empty, so the equality guard reduces to
the original comparison and the value is never preserved from an empty result.

Note: the ~3 minute timeout reported in the issue is the create/update
stabilization timeout. With this fix the configuration converges as soon as the
backend reports matching rules, so the operation completes within the default
window rather than timing out.

Relations

Closes #25939

References

Output from Acceptance Testing

Unit coverage for the equality guard, which encodes the asymmetric
empty-tolerance behavior:

% go test ./internal/service/s3/ -run '^TestLifecycleConfigEqual$' -v
=== RUN   TestLifecycleConfigEqual
=== RUN   TestLifecycleConfigEqual/observed_empty,_requested_non-empty,_rules_equal
=== RUN   TestLifecycleConfigEqual/observed_empty,_requested_empty,_rules_equal
=== RUN   TestLifecycleConfigEqual/observed_non-empty_differs_from_requested
=== RUN   TestLifecycleConfigEqual/observed_non-empty_equals_requested
=== RUN   TestLifecycleConfigEqual/observed_empty,_rules_differ
=== RUN   TestLifecycleConfigEqual/sizes_equal,_rules_differ
--- PASS: TestLifecycleConfigEqual (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/s3

@kayrus
kayrus requested a review from a team as a code owner September 8, 2026 21:43
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions Bot added needs-triage Waiting for first response or review from a maintainer. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/s3 Issues and PRs that pertain to the s3 service. size/L Managed by automation to categorize the size of a PR. labels Sep 8, 2026
…minimum_object_size when backend omits it

S3-compatible backends (e.g. Ceph RADOS Gateway) omit the
x-amz-transition-default-minimum-object-size field on GET. Preserve the
planned/prior value when the flattened value is empty, and tolerate an empty
observed value in lifecycleConfigEqual so stabilization can converge.
@kayrus
kayrus force-pushed the b-s3-lifecycle-transition-min-size-empty branch from 2380ad8 to 9464d5c Compare September 9, 2026 10:06
@kayrus

kayrus commented Sep 9, 2026

Copy link
Copy Markdown
Author

@gdavison @jar-b @ewbankkit @YakDriver could you please review this PR?

@justinretzolk

Copy link
Copy Markdown
Member

Similar #48457
Similar #49547

@justinretzolk justinretzolk added aws-compatible-service Issues related to compatibility with AWS-compatible services. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 10, 2026
@kayrus

kayrus commented Sep 10, 2026

Copy link
Copy Markdown
Author

@justinretzolk Thanks for your attention. The #48457 still doesn't work with the Ceph S3 backend. The flattenBucketLifecycleConfigurationResource helper func modification is still necessary.

the #49547 looks similar to my PR. Would be nice if you pick up one PR and review/merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws-compatible-service Issues related to compatibility with AWS-compatible services. service/s3 Issues and PRs that pertain to the s3 service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lifecycle configuration for S3 Bucket failing with time out issue for AWS Provider 4.21.0

2 participants