Infrastructure as Code in TypeScript with Pulumi

What is Pulumi and how it’s transforming the Cloud DevOps landscapeInfrastructure as Code (IaC) enables developers to configure and manage the Cloud infrastructure programmatically. There are many different IaC tools in the market. But learning and ado…


This content originally appeared on Bits and Pieces - Medium and was authored by Pavindu Lakshan

What is Pulumi and how it’s transforming the Cloud DevOps landscape

Infrastructure as Code (IaC) enables developers to configure and manage the Cloud infrastructure programmatically. There are many different IaC tools in the market. But learning and adopting such a tool isn’t easy.

Therefore an IaC tool with a minimum learning curve had always been a central point of discussion.

Why Pulumi?

Pulumi, an IaC tool released in mid-2018, seems to address this problem well. As a result, it is rapidly becoming one of the most popular IaC tools out there.

Let’s investigate why many DevOps teams have started picking up Pulumi as the IaC tool of choice.

1. Multi-language support

In contrast to other existing tools, Pulumi supports multiple general programming languages including Node.js, Go, Python, and my favorite language, TypeScript.

You can also write unit tests and integration tests, in your familiar testing libraries, to test your infrastructure configurations.

For example, we can create a new AWS S3 bucket and attach a lambda function as an event handler to it, using TypeScript.

import * as aws from “@pulumi/aws”;
// Create a bucket using IaC.
const myBucket = new aws.s3.Bucket(“mybucket”);
// Create an AWS Lambda event handler for the S3 bucket.
myBucket.onObjectCreated(“myBucketHandler”, (e) => {
// lambda function code goes here.
});

2. Consistent growth

It is already having 9.5K stars on GitHub and gained consistent growth with downloads.

Pulumi’s growth as shown in NPM trends — Screenshot by author

3. Generous free plan

If you want to try out Pulumi, you can start with their free tier, which is more than enough to do all your experiments before migrating without any cost. In addition, it is forever free for personal use, and there are 150,000 free credits each month, even if you are in the paid plan.

4. Dry-run support

Terraform is one of the leading IaC tools out there, famous due to its dry-run support. In Terraform, the terraform plan command shows a preview of the scheduled updates to a stack so that developers can verify that no unintended changes are deployed.

Pulumi too supports this dry run feature through the pulumi preview command. In addition, Pulumi utilizes Terraform providers if a native provider doesn’t exist.

Therefore, you shouldn’t worry if you are migrating to Pulumi from Terraform. Pulumi has already got you covered.

5. Easy migration from other IaC tools

Pulumi makes migrating from other IaC tools convenient. It has converters for the below types.

  • ARM (Azure Resource Manager) templates
  • Kubernetes CustomResourceDefinitions
  • Terraform HCL (Harshicorp Configuration Language)

Therefore, we can migrate from the above types to Pulumi-supported general-purpose language of your choice with semi-automation.

6. Convention over configuration

There are well-establish patterns in Cloud architecture to address specific problems. So, instead of writing IaC for each module, why not combine them and abstract away the complexities?

Pulumi CrossWalks precisely does this. It is a suite of libraries and best practices that allow us to provision Cloud Infrastructure in few lines of code. Besides, it ensures that we follow the industry best practices maximizing efficiency and security.

Using Pulumi in Practice

Let’s see how we can use Pulumi with AWS. The following code provisions a t2.micro AWS EC2 instance with the specified security rules.

Then, you can also write Unit Tests with any testing framework you prefer. Here I have used Mocha for the demo.

Build & share independent JS/TS components with Bit

Bit is an extensible tool that lets you create truly modular applications with independently authored, versioned, and maintained components.

Use it to build modular apps & design systems, author and deliver micro frontends & microservices, or share components between applications.

An independently source-controlled and shared “card” component. On the right => its dependency graph, auto-generated by Bit.

Bit: The platform for the modular web

Wrapping Up

Pulumi is gaining popularity with its multiple programming language support, including TypeScript.

Therefore, learning and getting adapted to it is much easier than any other IaC tool.

Different Infrastructure as Code Tools/Frameworks comparison chart

Although it’s relatively new, Pulumi continues to invade Devops pretty fast, despite the lack of learning resources. In my opinion, more and more DevOps teams will pick up Pulumi as their IaC tool of choice as more people get aware of it.

Thank you all for reading !!!

Learn More


Infrastructure as Code in TypeScript with Pulumi was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Bits and Pieces - Medium and was authored by Pavindu Lakshan


Print Share Comment Cite Upload Translate Updates
APA

Pavindu Lakshan | Sciencx (2021-08-17T14:12:23+00:00) Infrastructure as Code in TypeScript with Pulumi. Retrieved from https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/

MLA
" » Infrastructure as Code in TypeScript with Pulumi." Pavindu Lakshan | Sciencx - Tuesday August 17, 2021, https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/
HARVARD
Pavindu Lakshan | Sciencx Tuesday August 17, 2021 » Infrastructure as Code in TypeScript with Pulumi., viewed ,<https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/>
VANCOUVER
Pavindu Lakshan | Sciencx - » Infrastructure as Code in TypeScript with Pulumi. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/
CHICAGO
" » Infrastructure as Code in TypeScript with Pulumi." Pavindu Lakshan | Sciencx - Accessed . https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/
IEEE
" » Infrastructure as Code in TypeScript with Pulumi." Pavindu Lakshan | Sciencx [Online]. Available: https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/. [Accessed: ]
rf:citation
» Infrastructure as Code in TypeScript with Pulumi | Pavindu Lakshan | Sciencx | https://www.scien.cx/2021/08/17/infrastructure-as-code-in-typescript-with-pulumi/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.