terraform-aws-modules / terraform-aws-s3-bucket

Terraform module to create AWS S3 resources 🇺🇦

Home Page:https://registry.terraform.io/modules/terraform-aws-modules/s3-bucket/aws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: aws_s3_bucket_website_configuration always makes a change when optional routing_rules.condition is absent

jcschneider79 opened this issue · comments

Terraform Core Version

1.6.2

AWS Provider Version

5.16.1

Affected Resource(s)

aws_s3_bucket_website_configuration

Expected Behavior

create an s3 website configuration without a nested condition under routing_rule(s)

Actual Behavior

Every time a plan is run, a change is detected to add an empty condition under routing_rule

Relevant Error/Panic Output Snippet

Terraform will perform the following actions:

  # module.js-test-bucket.aws_s3_bucket_website_configuration.this[0] will be updated in-place
  ~ resource "aws_s3_bucket_website_configuration" "this" {
        id               = "www.js-test.com"
        # (4 unchanged attributes hidden)

      ~ routing_rule {
          + condition {}

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Terraform Configuration Files

module "js-test-bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "3.15.1"

  bucket = "www.js-test.com"


  # S3 bucket-level Public Access Block configuration
  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true

  attach_deny_insecure_transport_policy = true

  versioning = {
    enabled = true
  }

  server_side_encryption_configuration = {
    rule = {
      apply_server_side_encryption_by_default = {
        sse_algorithm = "AES256"
      }
    }
  }

  website = {
    index_document = "index.html"

    routing_rules = [
      {
        redirect = {
          host_name          = "foo.com"
          http_redirect_code = 301
          protocol           = "https"
          replace_key_with   = "js-test/"
        }
      }
    ]
  }

  tags = {
    Environment = "sandbox"
    managed_by  = "terraform"
  }
}

Steps to Reproduce

apply the TF code above. Immediately after applying, run another terraform plan and you will see that terraform detects that a change is necessary to add an empty condition under routing_rule

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None