DevOps tool of the month is a series, where each month I introduce one new useful DevOps tool in 2021 🙌🏼
For May I chose: Pulumi 🎉 - a modern Infrastructure as Code Tool for Developers.
When writing IaC scripts using other tools, you usually have to use a DSL (like HCL in case of Terraform) of that tool or YAML or JSON which is a format that many tools use.
Problem with YAML or JSON:
It's easy to read and easy to define resources you want to create and that is great.
But what if we need to add some logic in there, like
- conditionals, "create this EC2 instance, if xyz"
- or use loops, like "I want to create 20 EC2 Instances with the same configuration"
- or what about re-using logic? Like, "all 20 instances with this shared config, plus some specific configs"
It gets pretty complex in such formats. So all these logical operations, loops, reusing blocks of code is a natural part of any programming language, right?
So writing the same infrastructure as code logic in a programming language would obviously make writing more complex code easier and cleaner. And that's exactly what Pulumi did.
Pulumi allows you to write infrastructure as code in a programming language.
Now which programming language is that? 🤔 Well, you can actually choose whichever language you want to use Pulumi. You can write it in Node.js, Python, .net etc.
So instead of having to learn a new syntax or DSL or a new language, you can use the language you are most proficient in and use it for writing infrastructure as code. 👍
1) Use the same Programming Tools you know for Infrastructure
If you are coding in Python for example, you probably have the most fitting IDE for it, like PyCharm, you have installed all the plugins for that languages, you have configured linters that tell you immediately if you have an error in the code or warning in your code quality. You know all the main libraries you can use in your code etc.
So you know the whole eco-system of that language. And that means you can use all that same eco-system and your expertise for now writing infrastructure as code. And this can make your work much more efficient.
2) Treat Infrastructure as Code as Application Code
Another thing that we see emerging and becoming a standard is treating our infrastructure as code exactly the same way as our application code.
That includes e.g. testing the code. Having unit tests, integration tests etc. So with YAML and JSON format or DSL, like HCL that Terraform uses, it's pretty difficult to write tests for these scripts.
With Pulumi obviously you have the advantage of simply writing tests for you IaC as for your application code, using the same test libraries, same language, same editor etc. 🙌🏼
Check out the video to see how Pulumi works in practice. I will show you how to write a simple Pulumi project to first create an S3 bucket in an AWS account and then a more realistic example of provisioning an EKS cluster:
More awesome tools coming up next on this series, so stay tuned for it! 🎬 😊
Like, share and follow me 😍 for more content: