Live data from Hacker News

Unknown Values: The Secret to Terraform Plan

log.martinatkins.me

1–10 of 22 posts

Re: Unknown Values: The Secret to Terraform Plan

#2
> So returning to the original question: why doesn't Terraform use an existing language? So far, I've not yet encountered an existing language runtime which contains the building blocks Terraform uses in order to keep the plan-related promises.

That sure does sound like the author believes "pulumi preview" shouldn't ever work

Re: Unknown Values: The Secret to Terraform Plan

#3
post #2

> So returning to the original question: why doesn't Terraform use an existing language? So far, I've not yet encountered an existing language runtime which contains the building blocks Terraform uses in order to keep the plan-related promises. That sure does sound like the author believes "pulumi preview" shouldn't ever work

Yep, definitely disappointed that Pulumi was not mentioned.

Re: Unknown Values: The Secret to Terraform Plan

#4
post #2

> So returning to the original question: why doesn't Terraform use an existing language? So far, I've not yet encountered an existing language runtime which contains the building blocks Terraform uses in order to keep the plan-related promises. That sure does sound like the author believes "pulumi preview" shouldn't ever work

Does anyone have any experiences with Pulumi to share?

Re: Unknown Values: The Secret to Terraform Plan

#5
post #2

> So returning to the original question: why doesn't Terraform use an existing language? So far, I've not yet encountered an existing language runtime which contains the building blocks Terraform uses in order to keep the plan-related promises. That sure does sound like the author believes "pulumi preview" shouldn't ever work

I want so badly to use pulumi's tools, but relying on them as a 3rd party service is just not acceptable to me.

Re: Unknown Values: The Secret to Terraform Plan

#6
The section about promises is weird. Why would you do that? It's clearly a far better match for the kind of symbolic computation stuff lisp is famous for and functional languages in general tend to be good at, and that compilers often have to deal with (which being why those languages are so good at them). Heck, the article even mentions that `plan` is basically a compiler.

Re: Unknown Values: The Secret to Terraform Plan

#7
post #2

> So returning to the original question: why doesn't Terraform use an existing language? So far, I've not yet encountered an existing language runtime which contains the building blocks Terraform uses in order to keep the plan-related promises. That sure does sound like the author believes "pulumi preview" shouldn't ever work

I want so badly to use pulumi's tools, but relying on them as a 3rd party service is just not acceptable to me.

Just found out they do support alternative state backends like Terraform does.

Re: Unknown Values: The Secret to Terraform Plan

#8
I suspect you could implement this as a Haskell DSL.

The discussion part where you are not allowed (from Terraform lang) to create behavior dependent on the actual values of "Unknown" values (to prevent an ambiguous / non-deterministic plan), reminds of Applicatives vs Monads a bit.

(Sketchy potentially non-100% true illustration ahead)

For example, if you write a command-line parsing library using a Monad, then the set of command-line options is not an upfront fixed set easy to list with --help, but can change depending on previous command line options (here the command line parsing can peek into the upfront "Unknown" values, the options used and their values, to generate even more options).

While if you write it using Applicative, then peeking into the actual values is not possible, you can't create branching behaviour.

Re: Unknown Values: The Secret to Terraform Plan

#9
post #8

I suspect you could implement this as a Haskell DSL. The discussion part where you are not allowed (from Terraform lang) to create behavior dependent on the actual values of "Unknown" values (to prevent an ambiguous / non-deterministic plan), reminds of Applicatives vs Monads a bit. (Sketchy potentially non-100% true illustration ahead) For example, if you write a command-line parsing library using a Monad, then the…

...but maybe you don't need to go as far as Haskell. Any language with generics could work, like Java. (Or well, void pointers or anonymous interfaces..). Just make sure the user-written plan code doesn't get any meaningful info about the unknown values, only able to pass it around.

Re: Unknown Values: The Secret to Terraform Plan

#10
post #2

> So returning to the original question: why doesn't Terraform use an existing language? So far, I've not yet encountered an existing language runtime which contains the building blocks Terraform uses in order to keep the plan-related promises. That sure does sound like the author believes "pulumi preview" shouldn't ever work

Well... It's just my own personal opinion, but writing Pulumi code (be it Go or Python) feels like I'm writing a program that emits some Terraform-like code (conceptually, not the actual shape) under the hood and runs an interpreter afterwards. I've used that mode of operation because I needed to continuously update infrastructure to match database updates - there's another and probably more mainstream option is that Pulumi runtime runs a language runtime for me which feels even weirder as my program is not really a program but just an oddly-linked library.

I haven't really looked under the hood but I strongly suspect I'm not that far away from truth. At some point I've seriously considered a question why I'm not just templating HCL directly rather than dealing with all those Pulumi oddities.

Either way it feels very different and pretty much alien.

Post reply on HN