# Infrastructure as Code: exploring Pulumi

- URL: https://baeke.info/2019/01/20/infrastructure-as-code-exploring-pulumi/
- Author: Geert Baeke
- Published: January 20, 2019 (updated January 20, 2019)
- Topics: automation, azure, cloud, containers, dev, docker, nodejs, azure, cloud, devops, iac, pulumi

Image: from the Pulumi website

In my Twitter feed, I often come across [Pulumi](https://pulumi.io/) so I decided to try it out. Pulumi is an Infrastructure as Code solution that allows you to use familiar development languages such as JavaScript, Python and Go. The idea is that you define your infrastructure in the language that you prefer, versus some domain specific language. When ready, you merely use **pulumi up** to deploy your resources (and **pulumi update**, **pulumi destroy**, etc…). The screenshot below shows the deployment of an Azure resource group, storage account, file share and a container group on Azure Container Instances. The file share is mapped as a volume to one of the containers in the container group:

![](https://baeke.info/_astro/2019-01-image-29.CjSTblaX_Z1KsXDP.webp)

*Deploying infrastructure with pulumi up*

Installation is extremely straightforward. I chose to write the code in JavaScript as I had all the tools already installed on my Windows box. It is also more polished than the Go option (for now). I installed Pulumi per their instructions over at [https://pulumi.io/quickstart/install.html](https://pulumi.io/quickstart/install.html).

Next, I used their cloud console to create a new project. Eventually, you will need to run a **pulumi new** command on your local machine. The cloud console will provide you with the command to use which is handy when you are just getting started. The cloud console provides a great overview of all your activities:

![](https://baeke.info/_astro/2019-01-image-30.DXXdWgjD_ZlkIc0.webp)

*Nice and green (because I did not include the failed ones 😉)*

In Resources, you can obtain a graph of the deployed resources:

![](https://baeke.info/_astro/2019-01-image-31.B5yGGxRT_ZHi7wS.webp)

*Don’t you just love pretty graphs like this?*

Let’s take a look at the code. The complete code is in the following gist: [https://gist.github.com/gbaeke/30ae42dd10836881e7d5410743e4897c](https://gist.github.com/gbaeke/30ae42dd10836881e7d5410743e4897c).

![](https://baeke.info/_astro/2019-01-image-32.-iXcC4nc_icou.webp)

*Resource group, storage account and share*

The above code creates the resource group, storage account and file share. It is so straightforward that there is no need to explain it, especially if you know how it works with ARM. The simplicity of just referring to properties of resources you just created is awesome!

Next, we create a container group with two containers:

![](https://baeke.info/_astro/2019-01-image-33.BHDdHBT3_Z1EpDcu.webp)

*Creating the container group*

If you have ever created a container group with a [YAML](https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/container-instances/container-instances-multi-container-yaml.md) file or ARM template, the above code will be very familiar. It defines a DNS label for the group and sets the type to Linux (ACI also supports Windows). Then two containers are added. The realtime-go container uses CertMagic to obtain Let’s Encrypt certificates. The certificates should be stored in persistent storage and that is what the Azure File Share is used for. It is mounted on /.local/share/certmagic because that is where the files will be placed in a [scratch](https://hub.docker.com/_/scratch) container.

I did run into a small issue with the container group. The realtime-go container should expose both port 80 and 443 but the port setting is a single numeric value. In YAML or ARM, multiple ports can be specified which makes total sense. Pulumi has another cross-cloud option to deploy containers which might do the trick.

All in all, I am pleasantly surprised with Pulumi. It’s definitely worth a more in-depth investigation!
