4 ms·
Terraform is using a delarative DSL. CloudFormation is similar in that regard. Using a declarative language is both a pro and con. Pros of that solution is th
by pojzon 5y ago
Terraform is using a delarative DSL. CloudFormation is similar in that regard.
Using a declarative language is both a pro and con.
Pros of that solution is that you are restricted in what you can do, which often results in simplier and cleaner code.
Cons are that again you are restricted in what you can do.
Now about CDK is just your preferred language library to write infrastructure in imperative way. For example you write java code that deploys infrastructure.
When using a real programming language you have ofcourse a lot more freedom in what you do, but ofcourse that comes at the cost of complexity.
If your developers are “creative” it can be very hard to understand wth is happening in code.
—-
So yes many ppl consider Terraform as a golden standard (me included) but after many years of working with it, like anything in IT it has own flaws and you may want to consider other solutions for specific projects.
- jen20 5y agoCDK is also declarative - it generates a CloudFormation YAML file, so cannot possibly be anything else. Declarative is a property of a programming model, not a language.
- pojzon 5y agoInbetween using CDK and generating CF Template you can be very “creative”, thats where the imperative part lies.
- 8note 5y agoI think there's a much stronger argument that cloudformation deploying your stacks gets to being imperative than the way you produce your cloudformation file. The file is still declarative regardless, and the functions you write to create that file don't per se have side effects outside that file
- Too 5y agoIt’s possible, and very easy, to generate yaml with a bunch of for-loops and side-effects in an imperative language. So without knowing anything about cdk, even if it is declarative, I don’t think your conclusion is applicable. Terraform, the language, works differently. While it has variables, you can not store state in variables and depend on side effects based on the order you read/write such variables. Every assignment and execution order of resources is purely based on dependency order and not based on the order of the lines in your code.
- jen20 5y agoTerraform is not a language. HCL could be considered a language, but really requires the additional context of the Terraform resource model and the individual schema pertaining to the resources under management to decode. It populates an internal resource model, before changes are effected by the Terraform core engine. One can configure the self same resource model using JSON, which can be trivially generated - as you correctly point out - using whatever language and paradigm you like. However, since the language doing the generation does not influence the order of operations when applying the effects, the model is declarative. This is identical to the CDK configuring the CloudFormation engine via YAML. Indeed, there is a CDK for Terraform too...
- fdgsdfogijq 5y agoI'm a huge fanboy of CDK. I think its superior, and that its power has yet to be realized by the tech community at large. You can essentially create object oriented abstractions of common infrastructure patterns. You are correct, you need to be careful about how you build things, but it can be extremely productive. Cloudformation is a nightmare.