cloudposse / terraform-aws-tfstate-backend

Terraform module that provision an S3 bucket to store the `terraform.tfstate` file and a DynamoDB table to lock the state file to prevent concurrent modifications and state corruption.
https://cloudposse.com/accelerate
Apache License 2.0
408 stars 177 forks source link

fix crash: do not create policy when prevent_unencrypted_uploads is false #135

Closed dod38fr closed 1 year ago

dod38fr commented 1 year ago

what

This change avoids creating a policy object when prevent_unencrypted_uploads is set to false

why

With version 1.1.0, terraform apply fails with:

│ Error: Error putting S3 policy: MalformedPolicy: Policies must be valid JSON and the first byte must be '{'
│       status code: 400, request id: WZ7PGJ00QKNE2ZEJ, host id: qv+X4PBFIFqU6KIfIlyySSBBWRp0c4SgNFyu4Z71NJPI4x2x8uSopCZDdJ8nV96cxd+HMgG5gC4=
│ 
│   with module.s3-backend.module.terraform_state_backend.aws_s3_bucket_policy.default[0],
│   on .terraform/modules/s3-backend.terraform_state_backend/main.tf line 155, in resource "aws_s3_bucket_policy" "default":
│  155: resource "aws_s3_bucket_policy" "default" {
│ 

This change fixes this issue

references

Nuru commented 1 year ago

@dod38fr Thank you for your contribution.

Closing this PR in favor of #139