Pulumi supports programs written in Python 3.

Note: As of Pulumi 0.16.4, we have removed support for Python 2.7, and only support Python 3.6 or greater. You must have installed Python 3.6 prior to running Pulumi programs, or you will likely see syntax errors - Pulumi makes use of new Python syntax that is not backwards-compatible with Python 2. Older Pulumi versions did support Python 2.7.

Python 3 and pip3 are required by Pulumi.

Getting Started

The fastest way to get started with Pulumi Python is by using a template. From an empty directory in which you’d like to create a new project:

$ mkdir myproject && cd myproject
$ pulumi new python

This creates a Pulumi.yaml file, containing minimal metadata about your project (including a name and description, which you may wish to change), a requirements.txt file, where you will specify your dependencies (see #pypi-packages below), and a file, containing your program.

Note: Although the template uses a very simple package structure, by placing in the root directory, Pulumi fully supports properly modularized Python programs and files. This is important if you ever decide to turn your Pulumi program into a library.
Note: Pulumi expects the python executable to refer to a Python 3.6 or above. This is usually not the case when running outside of a virtual environment. To work around around this and explicitly ask Pulumi to run your program using python3, you can set the PULUMI_PYTHON_CMD environment variable to python3. This will be addressed in future versions of Pulumi.

Using Pulumi PyPI Packages

It is not required, but we recommend using a virtual environment such as venv to isolate the dependencies of your projects and ensure reproducibility between machines.

Adding a new dependency

The following Pulumi Python packages are available:

  • pulumi: the core Pulumi Python SDK package
  • pulumi_aws: the AWS resource provider package, for programming AWS directly
  • pulumi_azure: the Azure resource provider package, for programming Azure directly
  • pulumi_gcp: the Google Cloud resource provider package, for programming Google Cloud directly
  • pulumi_kubernetes: The Kubernetes resource provider package, for programming Kubernetes directly.
  • pulumi_vsphere: The VSphere resource provider package, for programming VSphere directly.
  • pulumi_openstack: The OpenStack resource provider package, for programming OpenStack directly.
  • pulumi_random: The Random resource provider package, for generating random strings, numbers, and other things while integrating nicely with the Pulumi programming model.

More packages are on their way, so please keep an eye out. Please also let us know if there are specific packages you’d like to see sooner!