Terraform 1.4.3: scenarios with Multiple `aws_iam_policy` Resources Referencing the Same Variable
I can't seem to get I'm working on a project and hit a roadblock. Quick question that's been bugging me - I'm working with an scenario when trying to define multiple `aws_iam_policy` resources in Terraform 1.4.3 that reference the same variable for policy document content. Specifically, I have the following setup in my configuration: ```hcl variable "s3_bucket_name" { description = "The name of the S3 bucket" type = string } resource "aws_iam_policy" "s3_read" { name = "S3ReadPolicy" policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Action = ["s3:GetObject" ] Resource = "arn:aws:s3:::${var.s3_bucket_name}/*" } ] }) } resource "aws_iam_policy" "s3_write" { name = "S3WritePolicy" policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Action = ["s3:PutObject", "s3:DeleteObject"] Resource = "arn:aws:s3:::${var.s3_bucket_name}/*" } ] }) } ``` I expected both policies to be created successfully, but I'm getting the following behavior when I run `terraform apply`: ``` behavior: Invalid JSON on .terraform/modules/my_module/main.tf line 10: 10: Resource = "arn:aws:s3:::${var.s3_bucket_name}/*" Invalid JSON: expected string or number ``` I have tried to troubleshoot the JSON structure by simplifying the policies to just include static strings, and that works. However, when I use the variable, it throws the behavior. I've also checked that the `s3_bucket_name` variable is being correctly passed in from the root module. Could this be related to how variables are interpolated in JSON encoding? Any insights on how to resolve this would be greatly appreciated! I'm working on a service that needs to handle this. Any ideas what could be causing this? This issue appeared after updating to Hcl 3.10. Cheers for any assistance! This is my first time working with Hcl stable. Is there a better approach?