Re:Terraform 1.0
by thanatos519 on Tuesday June 08, 2021 @08:57AM
(#27434520)
Amen! I found it excruciating that the language was always a few simple steps away from being homomorphic to JSON. I desperately needed to be able to manipulate it as data structures, not as strings. All of the ways I found to work around its limitations made me wish for something else entirely.
[ Parent
| on HN ]
Have you used it since they introduced HCL2? It supports other data structures much better than it used to. Maps, lists, sets, etc. are much easier to work with.
Re:Terraform 1.0
by throwaway894345 on Tuesday June 08, 2021 @11:03AM
(#27436126)
Still a far cry away from a proper programming language, which is what we need. For example, if you want to loop over some config and generate a resource for each config, but the resources need different providers (e.g., different AWS accounts) then you just can't do it. Further, if you just want a little function, you have to build a fully fledged module. Then there are the crazy namespaces (`var`, `local`, `resource`, `module`, etc).
Re:Terraform 1.0
by clipradiowallet on Tuesday June 08, 2021 @04:56PM
(#27440681)
Yes you can... assuming your config is a map, include a key for "provider", and set it appropriately. EG in your example for multiple AWS accounts, define providers aliased as `aws.account1`, `aws.account2`, and so on. Reference those provider aliases in your map you are iterating through, and set the provider to that value.
Re:Terraform 1.0
by throwaway894345 on Tuesday June 08, 2021 @05:06PM
(#27440798)
I'm 99% sure that will fail with an error because "provider" can't be set dynamically. See this issue, for example: https://github.com/hashicorp/terraform/issues/24476
You can write Terraform using JSON if you want to: https://www.terraform.io/docs/language/syntax/json.html
Or do you mean something deeper?
Re:Terraform 1.0
by thanatos519 on Tuesday June 08, 2021 @09:13AM
(#27434696)
I mean being able to reliably convert HCL↔JSON.
You can use JSON for your configuration: https://www.terraform.io/docs/language/syntax/json.html !
Re:Terraform 1.0
by rad_gruchalski on Tuesday June 08, 2021 @09:10AM
(#27434664)
It's a language for a reason, there's a grammar, parser, lexer, ast. What's the problem?