Creating a Pulumi Project

Infrastructure in Pulumi is organized into projects. In the Pulumi ecosystem, a project represents a Pulumi program that, when run, declares the desired infrastructure for Pulumi to manage. The program has corresponding stacks, or isolated, independently configurable instances of your Pulumi program. We’ll talk more about stacks later in the Building with Pulumi pathway.

Create a directory

Each Pulumi project lives in its own directory. Create one now and change into it by running these commands in your terminal:

mkdir my-first-app
cd my-first-app

Pulumi will use the directory name as your project name by default. To create an independent project, name the directory differently.

Initialize your project

Since a Pulumi project is just a directory with some files in it, it is possible for you to create a new one by hand. The pulumi new command-line interface (CLI) command, however, automates the process and ensures you have everything you need, so let’s use that command. Use Python for this tutorial (TypeScript, Go, and C# are coming soon!), and the -y flag answers “yes” to the prompts to create a default project:

$ pulumi new python -y

This command prints output similar to the following example with a bit more information and status as it goes (this example is in Python, but the basics are the same for any language):

Created stack 'dev'

Creating virtual environment...

Finished creating virtual environment

Updating pip, setuptools, and wheel in virtual environment...
...
Your new project is ready to go! ✨

To perform an initial deployment, run 'pulumi up'

This command creates all the files we need, initializes a new stack named dev (an instance of our project), and installs any necessary dependencies.

Inspect your new project

The basic project created by pulumi new is comprised of multiple files:

  • index.js index.ts `__main__.py` main.go MyStack.cs Program.fs MyStack.vb : your program's main entrypoint file
  • requirements.txt: your project's Python dependency information
  • Pulumi.yaml: your project's metadata, containing its name and language
  • venv: a virtualenv for your project

Use the command cat index.js index.ts __main__.py main.go MyStack.cs Program.fs MyStack.vb to explore the contents of your project’s empty program:

"""A Python Pulumi program"""

import pulumi

Feel free to explore the other files, although we won’t be editing any of them by hand.

Let’s move on to creating your first real bit of infrastructure with Pulumi: some Docker images.