Terraform 1.3.5: scenarios Creating S3 Bucket with Versioning Enabled and Custom Policy
I'm trying to implement This might be a silly question, but I'm working on a personal project and I'm trying to create an S3 bucket with versioning enabled using Terraform 1.3.5, but I'm running into issues with the bucket policy..... The configuration I'm using looks like this: ```hcl resource "aws_s3_bucket" "my_bucket" { bucket = "my-unique-bucket-name" versioning { enabled = true } } resource "aws_s3_bucket_policy" "my_bucket_policy" { bucket = aws_s3_bucket.my_bucket.id policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Principal = "*" Action = "s3:GetObject" Resource = "${aws_s3_bucket.my_bucket.arn}/*" } ] }) } ``` When I run `terraform apply`, I encounter the following behavior: ``` behavior: Invalid bucket policy: MalformedPolicy on .terraform/modules/my_module/main.tf line 12, in resource "aws_s3_bucket_policy" "my_bucket_policy": 12: policy = jsonencode({ ``` I've verified the bucket name is unique and the versioning block is correctly set, but I need to figure out whatβs malformed in the policy. I've also tried simplifying the policy to just allow `s3:ListBucket`, but I still get the same behavior. Could this be related to the use of `jsonencode`? Iβve looked at the AWS documentation on bucket policies and ensured my actions and resources are correct, yet Iβm still exploring. Any insights or suggestions on how to resolve this scenario would be greatly appreciated. This is part of a larger application I'm building. What am I doing wrong? I'm coming from a different tech stack and learning Hcl. I'd be grateful for any help.