Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

Migrating to Pulumi 2.0

Migrating to 2.0

Upgrading to 2.0 is simple. First, you will install the 2.0 CLI. Then, update each of your Pulumi programs to utilize the new SDK. If you’re using JavaScript or TypeScript, you’ll also need to ensure you’re using invokes asynchronously. We provide detailed instructions on each of these steps below.

Update CLI Scripts

Previously, the Pulumi CLI would assume --yes when used in non-interactive mode (i.e. when pulumi had its output piped to another process). You will now need to explicitly pass in --yes in those scenarios. This affects:

  • pulumi destroy
  • pulumi new
  • pulumi refresh
  • pulumi up

Update Your Pulumi Programs

Update Dependencies

npm install @pulumi/pulumi@^2.0.0

Remove synchronous invokes

Due to inconsistent support between versions of NodeJS, Pulumi 2.0 no longer supports synchronous invokes. As a result, the return value of all getSomething operations are now Promise<Something> values, instead of Something values, and should be processed using .then, async/await or by passing the results to pulumi.output(). Similarly, the StackReference operations getOutputSync and requireOutputSync are no longer supported and you should move to using the Output-based versions of getOutput and requireOutput.

const version: string = gcp.container.getEngineVersions().latestMasterVersion;

//After w/ Promise:
const version: Promise<string> = gcp.container.getEngineVersions().then(v => v.latestMasterVersion);

//After w/ Output:
const version: Output<string> = pulumi.output(gcp.container.getEngineVersions()).latestMasterVersion;

Optionally, you can use an async function entrypoint to more easily write async/await code throughout the rest of your program.

Update Dependencies

Modify your requirements.txt file to update the Pulumi SDK and related providers as below:


Then run pip install:

pip install -r requirements.txt

Update Dependencies

Pulumi 2.0 now supports Go modules. In go.mod, you can depend on the Pulumi SDK and related providers as below:

require ( v2.0.0 v2.0.0

Then run go mod download

Update Dependencies

Update your package reference to the latest version of the SDK:

<PackageReference Include="Pulumi" Version="2.*" />

Update Invokes

Functions in the Invokes namespace are now obsolete. Instead, use InvokeAsync which hangs off a static class named for the method being invoked.

For example, the following:

var clientConfig = await Pulumi.Azure.Core.Invokes.GetClientConfig();


var clientConfig = await Pulumi.Azure.Core.GetClientConfig.InvokeAsync();

Remaining on Pulumi 1.0

We recommend switching to Pulumi 2.0 if possible. We will only push critical security and bug fixes into the 1.x branch. Other fixes, feature enhancements, and new functionality will not be supported in the 1.x branch. In addition, provider updates will only be built against Pulumi 2.0.

If you wish to remain on the 1.x CLI, you can continue to download the CLI by referring to the manual installation instructions and choosing a specific version.

pulumi new will attempt to use the latest versions of the templates, which pull in the 2.0 SDK. You can continue to use the 1.x templates by running pulumi new

Note that previous 1.x templates for Python had >=1.0.0 in requirements.txt. As a result, you may accidentally end up on the 2.x SDK when updating dependencies from the 1.x template. We encourage updating to >=1.0.0,<2.0.0 if you intend to remain on the 1.x releases.