Pulumi
Pulumi’s infrastructure-as-code SDK helps you create, deploy, and manage AWS containers, serverless functions, and infrastructure using familiar programming languages. The endpoints configuration environment of Pulumi allows us to easily point Pulumi to LocalStack. This guide follows the instructions from Pulumi’s Get Started with Pulumi and AWS guide, with additional explanations of how to make it work with LocalStack.
First, run the following commands and follow the instructions in the CLI to create a new project.
We use the default configuration values:
Enter a value or leave blank to accept the (default), and press <ENTER>.
Press ^C at any time to quit.
project name: (quickstart)
project description: (A minimal AWS TypeScript Pulumi program)
Created project 'quickstart'
Please enter your desired stack name.
To create a stack in an organization, use the format <org-name>/<stack-name> (e.g. `acmecorp/dev`).
stack name: (dev)
Created stack 'dev'
aws:region: The AWS region to deploy into: (us-east-1)
Saved config
Installing dependencies...
This will create the following directory structure.
$ tree -L 1
├── index.ts
├── node_modules
├── package.json
├── package-lock.json
├── Pulumi.dev.yaml
├── Pulumi.yaml
└── tsconfig.json
Deploy the stack to LocalStack
Make sure your LocalStack is running. For the example stack, the only required service is S3. After updating the stack configuration, and starting localstack, you can run:
$ pulumi up
once the stack update was performed, you can run:
$ awslocal s3 ls
Where you should see something like
pulumilocal
is a wrapper script and drop-in replacement for the pulumi
CLI, that also provides commands to better interface Pulumi with LocalStack. You can find the source code repository here: https://github.com/localstack/pulumi-local
requires that you already have the pulumi
command in your path. Then, simply run
$ pip install pulumi-local
pulumi version
pulumilocal version
should output the same value.
Use
Instead of manually editing a stack configuration as explained earlier, you can run
which will create a Pulumi.localstack.yaml
stack configuration, and initialize an additional stack named localstack
.
You can now run
$ pulumilocal up
to start the localstack stack.