Warning
You're browsing the documentation for an old version of Webiny. Consider upgrading your project to Webiny 5.35.x.
What you’ll learn
  • why you might want to execute Pulumi commands
  • how to execute Pulumi commands via Webiny CLI

Introduction
anchor

Out of the box, Webiny CLI provides all of the essential commands that you might need in order to preview, deploy, and destroy your project applications’ cloud infrastructure resources.
To deploy necessary cloud infrastructure, by default, Webiny relies on Pulumi, a modern infrastructure as code framework. Find out more in the following IaC with Pulumi key topic.

And while in most cases these commands are enough to get the job done, still, there is a chance that you might need to use other specific Pulumi commands, via the Pulumi CLI external link.

For example, in case of the pending operations issue, you will most certainly want to execute the pulumi stack export external link and pulumi stack import external link commands, in order to repair your cloud infrastructure state files.

Unless you’ve installed the Pulumi CLI manually, trying to execute these in your terminal will result with an error, saying that the pulumi command was not found. Basically, this happens because Webiny doesn’t install the Pulumi CLI globally on your system. It’s set up locally and separately for every Webiny project, by downloading necessary binaries into a temporary folder, located in your Webiny project.

Because of this, Webiny CLI provides the pulumi command, which enables you to run any Pulumi command you might need. And not only that. Using Pulumi CLI through Webiny CLI will free you from setting some of the necessary environment variables and configuration params, because Webiny CLI handles these internally. For example, by specifying the environment via the --env argument, the Webiny CLI will automatically select the right Pulumi stack external link for you. No need for extra commands that would otherwise be needed, if we were using the standalone Pulumi CLI.

Pulumi’s programming model external link consists of three key concepts: Pulumi project external link, program external link, and stack external link.

The pulumi Command
anchor

Using the pulumi command is as simple as follows:

# Run the "stack export" command within the "api" project application,
# for the "dev" environment ("dev" Pulumi stack)
yarn webiny pulumi api --env dev -- stack export

# Run the "config set foo bar --secret" command within the "apps/admin" project
# application, for the "dev" environment ("dev" Pulumi stack)
yarn webiny pulumi apps/admin --env dev -- config set foo bar --secret

# Run the "refresh" command within the "apps/website" project application,
# for the "prod" environment ("prod" Pulumi stack)
yarn webiny pulumi apps/website --env prod -- refresh

As we can see, upon executing the pulumi command, we must provide three things:

  1. the project application folder (for example apps/website)
  2. the environment, via the --env argument
  3. the actual Pulumi command

Note that the --, used in shown examples, is not an error. The actual Pulumi command you want to execute must come after it, otherwise you will end up with unexpected results.

FAQ
anchor

What Is the Package Webiny Is Using to Execute Pulumi Commands?
anchor

We are using our own Pulumi SDK (@webiny/pulumi-sdk) external link, which is, essentially, a small wrapper over the original Pulumi CLI, that allows us to use it programmatically, via JavaScript code.

Where Is the Pulumi CLI Downloaded?
anchor

Pulumi CLI is downloaded into the following folder in your Webiny project: node_modules/@webiny/pulumi-sdk/pulumi.

Which Should I Use, Webiny CLI or Pulumi CLI?
anchor

Although both can be used to get the job done, we recommend you always rely on the Webiny CLI. This is because of the reasons mentioned in this guide:

  • no need to install the Pulumi CLI manually
  • no need to set extra environment variables and configuration params
  • anything that can be achieved with the Pulumi CLI can also be achieved with Webiny CLI

Troubleshooting
anchor

I'm Receiving the --yes must be passed in to proceed when running in non-interactive mode Error
anchor

This error may sometimes pop up because Webiny’s Pulumi SDK external link package runs all Pulumi commands in a non-interactive mode. Because of this, sometimes you will need to pass the --yes flag in order to confirm the execution of the Pulumi command you’re about to execute.