Infrastructure > Pulumi IaC
Execute Pulumi Commands
Learn how to execute Pulumi commands via Webiny CLI.
- why you might want to execute Pulumi commands
- how to execute Pulumi commands via Webiny CLI
Introduction
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.
For example, in case of the pending operations issue, you will most certainly want to execute the pulumi stack export
and pulumi stack import
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 for you. No need for extra commands that would otherwise be needed, if we were using the standalone Pulumi CLI.
Pulumi’s programming model consists of three key concepts: Pulumi project, program, and stack.
Thepulumi
Command
Using the pulumi
command is as simple as follows:
As we can see, upon executing the pulumi
command, we must provide three things:
- the project application folder (for example
apps/website
) - the environment, via the
--env
argument - 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
What Is the Package Webiny Is Using to Execute Pulumi Commands?
We are using our own Pulumi SDK (@webiny/pulumi-sdk), 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?
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?
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
I'm Receiving the--yes must be passed in to proceed when running in non-interactive mode
Error
This error may sometimes pop up because Webiny’s Pulumi SDK 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.