Skip to main content

Creating Pulumi Projects

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 tutorial.

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:

Terminal window
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. The -y flag answers “yes” to the prompts to create a default project:

Terminal window
pulumi new typescript -y

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

Terminal window
Created project 'my-first-app'
# ...
Installing dependencies...
# ...
Finished installing dependencies
Your new project is ready to go!
To perform an initial deployment, run 'pulumi up'

Inspect your new project#

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

  • Pulumi.yaml: your project’s metadata, containing its name and language
  • index.ts: your program’s main entrypoint file
  • package.json: your project’s Node.js dependency information

Open index.ts in your editor of choice to have a look at its contents:

import * as pulumi from "@pulumi/pulumi";

Feel free to explore the other files as well.

Now let’s move on to creating your first real bit of infrastructure with Pulumi: some Docker images!

Related

The infrastructure as code platform for any cloud.