Skip to content

Intermittent MissingRequestBodyError while creating aws_s3_bucket_replication_configuration #360

@nvnivs

Description

@nvnivs

Description

Occasionally, when creating a new S3 bucket with both Replication and Lifecycle configurations the apply fails with the following error:

│ Error: creating S3 Bucket (origin-s3-bucket-dear-pipefish) Replication Configuration: operation error S3: PutBucketReplication, https response error StatusCode: 400, RequestID: ---REDACTED---, HostID: ---REDACTED---, api error MissingRequestBodyError: Request Body is empty
│ 
│   with module.bucket_source.aws_s3_bucket_replication_configuration.this[0],
│   on ../../main.tf line 413, in resource "aws_s3_bucket_replication_configuration" "this":
│  413: resource "aws_s3_bucket_replication_configuration" "this" {

The root cause seems to be when the aws_s3_bucket_replication_configuration and the aws_s3_bucket_lifecycle_configuration resources creating a race condition when created in parallel.

Versions

  • Module version [Required]:

  • v5.7.0 (latest)

  • v4.3.0 (oldest version we tested with)

  • Terraform version:

Terraform v1.7.3
  • Provider version(s):
Providers required by configuration:
.
└── provider[registry.terraform.io/hashicorp/aws] >= 6.5.0

Reproduction Code [Required]

Steps to reproduce the behavior:

  • Create a configuration with both replication_configuration and lifecycle_rule
  • Init
  • Apply

Expected behavior

The module to apply successfully with the same configuration every time

Actual behavior

The module module creation only succeeds if aws_s3_bucket_replication_configuration creation is completed before aws_s3_bucket_lifecycle_configuration starts.

Additional context

Have created an example replicating the issue in a fork of this repo.

Also, have added an explicit dependency to the aws_s3_bucket_lifecycle_configuration which prevents this issue: https://github.com/nvnivs/terraform-aws-s3-bucket/blob/c255cb1e82698aaaea6feb095698398ebb318148/main.tf#L391-L396

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions