Pulumi

When working in cloud environments, it is useful to be able to define and statefully manage infrastructure. Pulumi is an Infrastructure as Code (IAC) utility that allows developers to programatically create, update, and delete cloud resources using programming languages such as Typescript, Javascript, Python, and Go.

Setup

  1. Download and install Pulumi following the instructions here.

  2. Confirm the CLI is successfully installed by running the following.

    Command

    pulumi version
    

    Example Output

    v3.39.1
    

  3. Within an empty directory, execute one of the following to create a Pulumi project for the target programming language.

    pulumi new aws-typescript
    
    pulumi new aws-javascript
    
    pulumi new aws-python
    
    pulumi new aws-go
    

  4. Once the Pulumi project has initialized, run the following command to ensure Pulumi is able to execute the project for the target language. The pulumi preview command will list which cloud resources will be generated by the Pulumi program. For a default Pulumi project, there should only be the default S3 bucket for data storage.

    Command

    pulumi preview
    

    Example Output

    Previewing update (dev)
    
    View Live: https://app.pulumi.com/username/test/dev/previews/5aa60450-112f-4394-99c7-233c13822001
    
         Type                 Name       Plan
     +   pulumi:pulumi:Stack  test-dev   create
     +   └─ aws:s3:Bucket     my-bucket  create
    
    Outputs:
        bucketName: output<string>
    
    Resources:
        + 2 to create
    

  5. To verify deployments are working as expected, execute the following:

    Command

    pulumi up -f
    

    Example Output

    Updating (dev)
    
    View Live: https://app.pulumi.com/username/test/dev/updates/1
    
         Type                 Name       Status
     +   pulumi:pulumi:Stack  test-dev   created
     +   └─ aws:s3:Bucket     my-bucket  created
    
    Outputs:
        bucketName: "my-bucket-9f5953e"
    
    Resources:
        + 2 created
    
    Duration: 6s
    

  6. Once the above runs successfully, run the following to delete any provisioned resources.

    Command

    pulumi down -f
    

    Example Output

    Destroying (dev)
    
    View Live: https://app.pulumi.com/username/test/dev/updates/2
    
         Type                 Name       Status
     -   pulumi:pulumi:Stack  test-dev   deleted
     -   └─ aws:s3:Bucket     my-bucket  deleted
    
    Outputs:
      - bucketName: "my-bucket-fb2b85f"
    
    Resources:
        - 2 deleted
    
    Duration: 4s