3 ms·
> code should be optimised to be easy to READ You say that as if it’s impossible to write clear code. As soon as you have any form of multiple resources (e.g.
by Aeolun 2y ago
> code should be optimised to be easy to READ
You say that as if it’s impossible to write clear code. As soon as you have any form of multiple resources (e.g. create x of y) I’ll take the real programming language over terraform.
- dijksterhuis 2y ago> As soon as you have any form of multiple resources terraform handles this with for_each. need 10 EBS volumes on 10 EC2 instances? for_each and link instance id of the each value. done. theres a bunch of stuff i now don’t have to worry about (does the instance actually exist yet? other validation edge cases?) https://developer.hashicorp.com/terraform/language/meta-arguments/for_each https://developer.hashicorp.com/terraform/language/meta-argu... > You say that as if it’s impossible to write clear code. not the parent, but i feel their usage of the word “code” was in error. i don’t care about how, i care about what. the HCL is purely a defintion/description of what the infrastructure looks like. what resources will be created? that is all it is. i want that. to define the infra and move on. i don’t want low level control of every minutia to do with infrastructure. i want to read a config file and just know what resources will exist in the account. wanna know every resource that exists? `terraform state list` … job done. no reading code required. HCL/terraform is to define my cloud resources, not to control them or their creation. if i want control, then i need to whip out some go/python. that’s my vibe on CDK libraries/platform APIs versus terraform.
- Aeolun 2y agoI don’t understand how these things follow. I’ll be the first to agree that CDK sucks, but Pulumi is essentially Terraform as a programming language, with all the niceties of terraform and more besides. The format that defines what infra looks like is… very hard to parse with terraform (for me). It seems optimized for defining a list of static resources, and everything else is bolted on. The for_each or count constructs do not make intuitive sense to me anyway. That said, by all means, use Terraform, as long as it’s not CDK I’ll be happy.
- Spivak 2y agoYou can understand every single terraform codebase using nothing other than the terraform documentation itself. All abstractions are provided by the language itself. Clear isn't really the word I would call it, more that the real work being done is exposed and always visible.
- Aeolun 2y agoModules aren’t provided by the language though?
- paulddraper 2y agoFortunately, Terraform has CDKTF [1] which allows you to use common languages such as Python, Java, and TypeScript to author Terraform infra. I used it daily and find it greatly liberating. [1] https://developer.hashicorp.com/terraform/cdktf https://developer.hashicorp.com/terraform/cdktf