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:

    1. Enter a value or leave blank to accept the (default), and press <ENTER>.
    2. Press ^C at any time to quit.
    3. project name: (quickstart)
    4. project description: (A minimal AWS TypeScript Pulumi program)
    5. Created project 'quickstart'
    6. Please enter your desired stack name.
    7. To create a stack in an organization, use the format <org-name>/<stack-name> (e.g. `acmecorp/dev`).
    8. stack name: (dev)
    9. Created stack 'dev'
    10. aws:region: The AWS region to deploy into: (us-east-1)
    11. Saved config
    12. Installing dependencies...

    This will create the following directory structure.

    1. $ tree -L 1
    2. ├── index.ts
    3. ├── node_modules
    4. ├── package.json
    5. ├── package-lock.json
    6. ├── Pulumi.dev.yaml
    7. ├── Pulumi.yaml
    8. └── 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:

    1. $ pulumi up

    once the stack update was performed, you can run:

    1. $ 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

    1. $ pip install pulumi-local
    1. pulumi version
    2. 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

    1. $ pulumilocal up

    to start the localstack stack.

    Articles