Getting Started with Pulumi

Session Overview

  • Launch your First Stack
  • Organizations, Projects, Stacks
  • State Management
  • Credential Management
  • Languages
  • Packages
  • Update your Stack
  • Delete your Stack

Launch your First Stack

  1. Run cd ~

  2. Make a new directory: mkdir {username}-stack

  3. Move to new directory.

  4. Run pulumi new

  5. Choose template.

  6. Choose aws-python.

  7. Keep project name as {username}-stack.

  8. Add project description!

  9. Stack Name: dev

  10. Use pip for the program

  11. Region: us-east-1

  12. Sit back and enjoy…

Launching your First Stack

  1. Run pulumi up.

  2. Walk through prompts - Look at the details.


  1. Check the results:

    • AWS Console
    • Pulumi Dashboard

Session Overview

  • Launch your First Stack
  • Organizations, Projects, Stacks
  • State Management
  • Credential Management
  • Languages
  • Packages
  • Update your Stack
  • Delete your Stack

Organizations, Projects, Stacks (Oh My!)

Organizations

  • Groups of users and resources.
  • Manage access and collaboration at scale.
  • Our organization is ncics.

Projects

  • Logical grouping of stacks.
  • Share common settings and configurations.
  • Typically maps to a single GitLab Repo (or Group).

Stacks

  • Isolated instances of a project (e.g., dev, staging, prod).
  • Manage state independently.
  • Can support multiple clouds and regions, though typically one.

State Management

  • Pulumi stores state to keep track of resource changes.
  • State can be stored locally or in the Pulumi Service.


Useful Commands

  • View State: pulumi stack
  • Export State: pulumi stack export > state.json
  • Refresh State: pulumi refresh

Credential Management

Session Overview

  • Launch your First Stack
  • Organizations, Projects, Stacks
  • State Management
  • Credential Management
  • Languages
  • Packages
  • Update your Stack
  • Delete your Stack

Languages

Pulumi supports many languages via their SDKs. They continue to add more here


  • NodeJS, JavaScript, TypeScript
  • Python
  • Go
  • .NET
  • Java
  • YAML

Packages

MANY!


Pulumi Registry

Pulumi Ecosystem

Session Overview

  • Launch your First Stack
  • Organizations, Projects, Stacks
  • State Management
  • Credential Management
  • Languages
  • Packages
  • Update your Stack
  • Delete your Stack

Update your Stack

  1. Add the following to your __main__.py
# __main__.py
from pulumi_aws import sns

sns_topic = sns.Topic("s3_updates")

pulumi.export('sns_topic_arn', sns_topic.arn)


Your __main__.py should look like this:

import pulumi
from pulumi_aws import s3
from pulumi_aws import sns

# Create an AWS resource (S3 Bucket)
bucket = s3.Bucket('my-bucket')

sns_topic = sns.Topic("s3_updates")

# Export the name of the bucket
pulumi.export('bucket_name', bucket.id)
pulumi.export('sns_topic_arn', sns_topic.arn)

Update your Stack

  1. Run pulumi up


Check out the details, deploy it, and check your results.

Delete your Stack

  1. Run pulumi destroy.

Recap:


It’s a Pulumi Party!


At this point:

  • You have Launched, Updated, and Destroyed your First Stack
  • You can use the Pulumi Dashboard to monitor state.
  • You can find more information through the Pulumi Registry in your desired language.