Write once, run on any cloud with Pulumi

Automating repetitive tasks is a basic cornerstone for maximizing efficiency and operational excellence at the industrial level. Coding your cloud infrastructure streamlines the development process, and also makes iterative development for your applications easier to manage. There are a number of sophisticated tools at your disposal as far as Infrastructure as Code (IaC) is concerned. Each of those tools has its own rules (mostly a Domain Specific Language — DSL) and concepts of implementation, so before you can become efficient, you need to spend some time understanding how they work to begin the implementation process.
Pulumi is a platform for creating, deploying, and managing cloud infrastructure along with offering multi-cloud support like most other IaC tools. The distinction between Pulumi and other tools is that with Pulumi you can program the infrastructure in the language you’re familiar with. This means you can start coding your cloud deployments without spending any time on learning a new language.
How Pulumi works:
This IaC tool operates using a state-driven approach. Pulumi leverages existing, familiar programming languages, including TypeScript, JavaScript, Python, Go, and .NET, and their native tools, libraries, and package managers. Following a declarative approach using the SDK, you allocate a resource object whose properties and attributes indicate the desired state of your infrastructure.
When a Pulumi program executes, the flow is as follows
- A language host computes the desired state for a stack’s infrastructure. It sets up an environment where it can register resources with the deployment engine.
- The deployment engine compares this desired state with the stack’s current state and determines what resources need to be created, updated or deleted.
- The engine utilizes a set of resource providers (AWS, Azure etc.) in order to manage the individual resources.
Getting started:
Let’s explore the workings of Pulumi with an AWS lambda function that translates any non-English content to English when a text file is uploaded into an S3 bucket.
After you have created an account, the first requirement is to install the SDK. Depending on your OS, you can install by running
- brew install pulumi — MacOS
- choco install pulumi — Windows
- curl -fsSL https://get.pulumi.com | sh — Linux
Configure your service provider’s CLI so that Pulumi can carry out the operations for deployment. Since we are using AWS, we can either export the AWS_PROFILE name if there are multiple profiles (in the case that default profile is to be used you ignore this step) configured, or after creating a Pulumi project (next step) you can run this
pulumi config set aws:profile <profilename>Creating a project & deploying:
Javascript is the language we’ll work with for creating this project. Inside an empty directory, run
pulumi new aws-javascriptYou will first be prompted to log in to Pulumi when you initially start working with the CLI. After login, the CLI will create a project with your inputs (tip: leave us-east-1 as default since certain AWS services are not available in all regions) and automatically install base dependencies.
A typical JS Pulumi project will consist of the following files.
- Pulumi.yaml — Defines the project.
- Pulumi.dev.yaml — Contains configuration values for the stack we initialized.
- index.js — The Pulumi program that defines our stack resources.
Let’s begin adding in the code required to create our serverless function for text translation. There are two approaches to creating and deploying the function.
Manual function:
Replace the contents of index.js with the following code.









