Skip to content

HCL: HEREDOC invalid escapingΒ #3716

Open
@universam1

Description

Expected Behavior

For a multiline string, which is rendered into a HEREDOC for HCL output, the quotes should not be escaped.
Vault policy or AWS IAM policy render invalid.

Actual Behavior

Synth renders invalid strings, that are causing errors to apply at Vault or AWS.

Code: 400. Errors: * failed to parse policy: At 2:19: illegal char

Steps to Reproduce

y := `
path "secret/*" {
   capabilities = ["create", "read", "update", "delete", "list"]
}
`
policy.NewPolicy(stack, jsii.String("policy"), &policy.PolicyConfig{
	Name:   jsii.String("test),
	Policy: jsii.String(y),
})

Results into:
cdktf synth -hcl
Note the escaped quotes:

resource "vault_policy" "policy" {
  name   = "test"
  policy = <<EOF

        path \"secret/*\" {
          capabilities = [\"create\", \"read\", \"update\", \"delete\", \"list\"]
        }
        
EOF
}

Versions

language Golang
"version": "0.20.8"
same problem with 0.21.0-pre.123

Providers

  • aws
  • vault

Workarounds

try to use a single line statement, like a minified json.

Anything Else?

No response

References

try the example of https://github.com/ahmadalibagheri/cdktf-go-aws-iam

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnewUn-triaged issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions