-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hclwrite printing maps over multiple lines #356
Comments
I have similar problem but for keep multiline format for list element. I want to append a new element to an existing hcl list programmatically. Any recommendations for how to achieve this? |
@apparentlymart I'm sure you're busy but when you get a chance, do you any thoughts on this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using hclwrite to print some Terraform resource arguments that are maps. I'm having trouble getting them to span multiple lines using the higher-level hclwrite functions. Similar to #347, I'm wondering if this can be achieved with
SetAttributeValue
or if I'll need to resort toSetAttributeRaw
.This gist shows my three attempts:
SetAttributeValue
on the entire map value. This is the exact syntax I'm looking for except it is all on one line rather than separate lines per key-value pair.AppendNewBlock
and separateSetAttributeValue
s per pair. This is missing the equals sign as well as quoting around the first key, causing it to be treated as a division expression.SetAttributeRaw
on the entire contents of the map. This outputs what I want, I'm just wondering if theres a simpler way.HCL Template
The generated HCL from the above gist:
The desired HCL:
As mentioned, this can be achieved with my third attempt in the gist plus some extra logic around optionally quoting the keys which would be trivial to implement.
Is there an easier way to achieve this with hclwrite or should I continue with
SetAttributeRaw
or perhaps some other utility function likehclwrite.Format
? Any input would be greatly appreciated. Thanks!The text was updated successfully, but these errors were encountered: