Skip to content

Conversation

kunickiaj
Copy link
Contributor

Description

When creating replicated buckets, expose a versioning status output in order to be able to create a dependency on replica buckets being ready (versioning enabled). Otherwise applying replication rules targeting a bucket which isn't fully set up may fail.

Motivation and Context

There is no data source for bucket versioning status or exposed attributes for versioning except the aws_s3_bucket_versioning resource which is currently encapsulated by this module.

Take the following (abbreviated) example:

module "bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "5.2.0"

  bucket = "my-bucket"

  replication_configuration = {
    ....
  }
  
  versioning = {
    enabled = true
  }
}

module "replica_bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "5.2.0"

  bucket = "my-bucket-replica"

  versioning = {
    enabled = true
  }
}

This may result in:

Error: creating S3 Bucket (my-bucket) Replication Configuration: operation error S3: PutBucketReplication, https response error StatusCode: 400, RequestID: xxxx, HostID: xxxxx, api error InvalidRequest: Destination bucket must have versioning enabled.

The hope is that by depending on the versioning resource could delay replication rule creation until the destination bucket is ready (and has versioning configuration fully applied).

Breaking Changes

No breaking changes

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@antonbabenko antonbabenko changed the title Add bucket versioning status as an output feat: Add bucket versioning status as an output Aug 1, 2025
@antonbabenko
Copy link
Member

@kunickiaj Please fix the failing CI before the merge.

@kunickiaj kunickiaj force-pushed the ajk--versioning-output branch from 5f3875c to 44e2667 Compare August 1, 2025 22:35
@kunickiaj
Copy link
Contributor Author

@kunickiaj Please fix the failing CI before the merge.

manually updated to match, i think. might be some version mismatch. locally terraform-docs is outputting a different order.

@antonbabenko
Copy link
Member

@kunickiaj Something is not right there still.

When creating replicated buckets, expose a versioning status output in
order to be able to create a dependency on replica buckets being ready
(versioning enabled). Otherwise applying replication rules targeting a
bucket which isn't fully set up may fail.

Signed-off-by: Adam Kunicki <[email protected]>
@kunickiaj kunickiaj force-pushed the ajk--versioning-output branch from 44e2667 to 72eaef8 Compare August 4, 2025 04:24
@kunickiaj
Copy link
Contributor Author

fairly certain this should be correct

@antonbabenko antonbabenko merged commit 525f43c into terraform-aws-modules:master Aug 5, 2025
18 checks passed
antonbabenko pushed a commit that referenced this pull request Aug 5, 2025
## [5.3.0](v5.2.0...v5.3.0) (2025-08-05)

### Features

* Add bucket versioning status as an output ([#350](#350)) ([525f43c](525f43c))
@antonbabenko
Copy link
Member

This PR is included in version 5.3.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants