2 ms·
This article doesn't really get at the core of the distinction between tools like Ansible, chef, terraform and pulumi/AWS CDK. There are two languages being dis
by habitue 4y ago
This article doesn't really get at the core of the distinction between tools like Ansible, chef, terraform and pulumi/AWS CDK. There are two languages being discussed here:
- the language the programmer writes in
- the language that specifies the desired state of the infra.
You want the language you're writing to be a good language (ie, a language you are productive in). It's very helpful for the language the config is specified in to be a declarative manifest. That doesn't mean you as a programmer have to write that manifest language directly.
Pulumi and CDK are libraries that allow imperative languages to generate a declarative manifest.
Terraform is a (very hamstrung) declarative language that is also a declarative description of the desired infrastructure state. It is hard to use because the language is bad. But the language is bad for no reason because it confuses the very desirable property that you want a declarative config with the totally undesirable property that you generate that config with a crippled declarative DSL.
Ansible shows another side of this: it's a crippled declarative DSL that executes an imperative set of instructions to get the infrastructure into the desired state. The best you can say about the yaml straightjacket is that it causes you to organize your code with some structure, kinda like MVC web frameworks. But yaml's declarative nature doesn't impart any magic by itself. If you write a step that isn't idempotent, it just isn't idempotent.
If you find yourself wanting to add templates, and loops, and references etc to yaml: this is a smell that you should not be writing yaml. You should use a real programming language to generate yaml. That's essentially what Pulumi and CDK are doing. You can think of your real programming language (python or typescript or whatever) as a macro language that outputs the declarative config.
(For completeness, chef/bash deploy scripts are imperative languages that generate imperative commands to change the infra. Needless to say, this results in a mess usually)
- AaronFriel 4y agoPulumi does not generate a declarative manifest, your infrastructure program runs at the same time as the engine which applies resource operations. This allows you to use API calls, sleeps, and so on. It's a much more powerful model, and lets you use arbitrary computations between resources, using the output state of one to make an API call or some side effect, and plumb the result of that into the input of another resource. Full disclosure: I'm at Pulumi.
- trallnag 4y agoBut Pulumi still uses Terraform providers for many resources? And isn't it just as difficult to have multiple providers that depend on each other in the same stack?
- AaronFriel 4y agoNot exactly, it's a little more nuanced than that. I've done demos using our EKS provider to spin up a cluster, outputting a kubeconfig property and plumbing that into a Kubernetes provider to deploy a Helm chart to the cluster. It's 3 resources and fits on a single screen in most of our languages.
- ragall 4y agoYou call that "powerful", I'd call it a nightmare.
- habitue 4y agoAh, ok my mistake. I was under the impression that Pulumi worked like CDK (except compiled to terraform) and wasn't imperative.