Design your cloud infrastructure in the language you know with Pulumi

June 25, 2020


With all the variety of options out there to code your application's infrastructure for the cloud, I recently worked with Pulumi. If you have ever used Hashicorp's Terraform, AWS's Cloudformation or Red Hat's Ansible for designing cloud infrastructure, the one thing they all have in common is a framework of rules and standards which have to be followed. Pulumi differs from all of them by giving you the option to pick the programming language you want to work with when designing for the cloud.

Pulumi supports Typescript, Javascript, Python, Go & C#. No YAML/JSON or Domain Specific Languages (DSL), just the language you speak! Starting to work with Pulumi is a great advantage to those who have just stepped into coding infrastructures for the cloud because you don't have to learn a new language. You can start almost immediately with something you already know.

How it works:

The program is executed by a language host which computes the desired state of the stack's infrastructure. A deployment engine determines what resources need to be created, updated or destroyed based on the comparison it makes with the desired state and the current state of the stack. In short, Pulumi works by creating resources to achieve the desired state based on how you program the deployment code.

Let's explore a simple example with AWS where we deploy a Lambda function that is triggered when an image is uploaded an S3 bucket. The function calls the Rekognition API for identifying celebrity faces and stores the result into a DynamoDB table. All of these resources will be deployed without any manipulation at the console.

Follow the quick start guide from here. It's straight forward and simple to follow. I have used python for this program, which you can obtain from my github.

pulumi_rekognition_code

Deployment is as simple as running the command pulumi up. Once you deploy, the stacks you create show at Pulumi's console where you can explore all details such as the resources created, the AWS CLI profile used for deployment, environment variables and more.

To destroy the stack just run pulumi destroy. pulumi stack rm completely removes the stack from the pulumi console as well.

Pulumi also makes the transition from your current IaC framework seamless. Specifically, if you are looking to move from Terraform, t2fpulumi is a tool which can simplify that process. Refer their doc for more details.

Drop a comment or reach me on twitter if you need any help.


Share
Return to blog