Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

An easy way to get someone to admit that terraform is a hacky child’s language is to ask how to simply print out the values of variables and resources you are using in terraform easily. This basic programming language 101 functionality is not present in the language


  $terraform console
  >var.whatever
  "its value"
  >whatever_resource.foo.whatever_attr
  "its value"
If you mean somehow printing things when the configuration is being applied... I think you just need to understand that it's neither a procedural language (it's declarative) nor general-purpose (it's infrastructure configuration).


Declarative language can absolutely print out what it does know at the time. Which of course won’t be everything. But if I’m taking an input and morphing it at runtime like looping or just moving the information around in a data structure which terraform absolutely allows you to do, the runtime of terraform has all that information. I just can’t get it out.

Plus, there are many times I don’t want to have to use the REPL. Maybe I’m in CI or something. The fact that I cannot iterate over values of locals and variables easy to see what they are in say, some nested list or object, easily and just print out the values as I’m going along for the things terraform does know is just crappy design


This works great for toy examples and fails the moment you have 1 (one) module


It doesn't fail, but you're right you can't reach inside submodules with terraform console; I wish you could.


It "fails" in that I cannot use it to debug my code or print out outputs like the . In general, Terraform's debuggability story is very poor, and the DX tools (like the VS Code plugin) are lacking


HCL isn’t a programming language. This seems to be the main misconception about it and Terraform.


Any sufficiently large configuration language eventually becomes Turing complete (or close to it). See HCL, GitHub actions, kubernetes.


Kubernetes is not like the others in that list because it remains a declaration of intended state. There are for sure no "if", "loop", or even variables in the .yaml files. You may be thinking of the damn near infinite templating languages that generate said yaml, or even Kustomize that is JSONPatch-as-a-Service. GHA is not like the others because it is an imperative scripting language in yaml, not a "configuration language"


> Kubernetes is not like the others in that list because it remains a declaration of intended state

Mutation via hook?


It’s so infuriatingly close though which is what makes it so fucking annoying to work with. It has loops, conditionals, variables…


Indeed, it's the worst case of uncanny valley syndrome!


I agree that terraform is hacky, but is "terraform output {variable name}" not how you would do that?


You have to be able to actually specify the output. And that does not handle all use cases. And it has requirements on how it can be run. And it takes the full lifecycle of the plan. And it won’t work in many circumstances without an apply.

So no. Terraform has the information internally in many cases. There’s just no easy way to print it out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: