Aws s3 bucket cors configuration defaults value mismatch

resource “aws_s3_bucket_cors_configuration” “sample-rule” {
bucket = “xyz”

cors_rule {
allowed_methods = [“GET”, “HEAD”]
allowed_origins = [“*”]

  • Both allowed_methods and allowed_origins are mandatory fields as per Terraform Registry

  • Applying above code block sets max_age_seconds as 0 which is bit unusual behavior as it should be null and shouldn’t set to 0

  • Applying cors rule using aws cli command doesn’t seems to add max_age_seconds as 0, something on terraform aws provider side causing this behavior.

aws s3api put-bucket-cors --bucket xyz --cors-configuration file://cors.json

  • Terraform version - 1.3.9
  • Terraform AWS Provider version - 4.56.0