Pulumi - IaC in your favorite programming language!
Tags: pulumi, devops, iac, tutorial
Published: 2021-05-28 14:13:04

[DevOps tool of the month](https://www.youtube.com/playlist?list=PLy7NrYWoggjztwSskGu59O38gL5v0LjUT) is a series, where each month I introduce one new useful DevOps tool in 2021 🙌🏼

For May I chose: [**Pulumi**](https://www.pulumi.com/) 🎉 - a modern Infrastructure as Code Tool for Developers.

---
{% youtube vIjeiDcsR3Q %}
---

## What is Pulumi and how it's different from other IaC tools 💡 ##
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.

![Pulumi - choose favorite language](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ryr4w2aho4xr83hvkxo1.png)

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. 👍

## Main Benefits of using a Programming Language of your choice 🤩 ##

**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.

![Use Programming Expertise for Infrastructure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bd3jaiwrxbi8macvelsf.png)

**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**.

![One Pipeline for Everyone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r962ers9e2jt6cfwn4c8.png)

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. 🙌🏼


## How Pulumi works in Practice 👩🏻‍💻 ##
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:
![Pulumi Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lj9zjuaz9rnth1vloftv.png)

---

More awesome tools coming up next on this series, so stay tuned for it! 🎬 😊

---

**Like, share and follow me** 😍 for more content:
- [Private FB group](https://www.facebook.com/groups/techworldwithnana)
- [Twitter](https://twitter.com/Njuchi_)
- [YouTube](https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA?sub_confirmation=1)
- [Instagram](https://www.instagram.com/techworld_with_nana/)
- [LinkedIn](linkedin.com/in/nana-janashia)