The pulumi up command serves as the primary operational engine for the Pulumi Infrastructure as Code (IaC) platform. It is the critical mechanism used to create, update, and maintain the physical state of cloud resources by aligning them with the desired state defined in a Pulumi program. Unlike traditional imperative scripts that execute a sequence of steps to build a server or network, pulumi up operates on a declarative model. It analyzes the current state of the infrastructure, compares it to the goal state expressed in the code, and computes the most minimally disruptive set of operations—create, read, update, and delete—to achieve that target.
At its core, the execution of pulumi up triggers a complex lifecycle. First, it runs the Pulumi program to generate a resource graph, which represents the intended architecture. This graph is then compared against the existing state snapshot. This comparison allows Pulumi to determine exactly what has changed. For instance, if a developer modifies a server plan in a Python file from 1xCPU-1GB to 2xCPU-2GB, the pulumi up command detects this specific difference. It does not blindly recreate the server; instead, it identifies the update operation required to modify the resource in place, provided the cloud provider supports such an action.
The operational impact of this command is profound for developers and system administrators. It transforms infrastructure management from a manual, error-prone process into a predictable, version-controlled workflow. By utilizing standard programming languages such as Python, TypeScript, Go, and C#, users can leverage loops, functions, and object-oriented principles to define their infrastructure. The pulumi up command then translates these high-level abstractions into actual API calls to cloud providers like AWS or UpCloud.
Furthermore, the command ensures transactional integrity. After the desired changes are applied, pulumi up records a full transactional snapshot of the stack's new state. This state management is vital because it allows subsequent updates to be incremental. Without this persistent record, the system would lose track of the relationships between resources, making it impossible to perform precise diffs or target specific resources for updates.
The Resource Graph and Goal State Computation
When a user executes pulumi up, the CLI does not immediately send commands to the cloud provider. Instead, it initiates a goal state computation process. The program is executed in the current directory, and Pulumi observes all resource allocations to produce a resource graph.
This graph is a mapping of every resource the user intends to deploy and the dependencies between them. For example, a virtual machine depends on a network interface, which in turn depends on a virtual network. By understanding these dependencies, pulumi up can determine the optimal order of operations.
The computed goal state is then compared against the existing state of the stack. This comparison identifies the delta—the difference between what is currently deployed and what is requested in the code. The objective is to reach the goal state in the most minimally disruptive way. If a resource exists and matches the code, it is left unchanged. If it exists but differs, it is updated. If it does not exist, it is created. If it exists in the state but is missing from the code, it is deleted.
Command Execution and Syntax
The basic syntax for the command is pulumi up [template|url] [flags]. While the most common usage is simply calling the command without arguments in a project directory, the CLI provides significant flexibility for different deployment scenarios.
By default, Pulumi loads the program from the project in the current working directory. However, users can specify a different directory using the -C or --cwd flags. This allows for the management of multiple projects from a single terminal session without needing to change directories manually.
Another powerful feature is the ability to deploy from templates. A user can provide an optional template name or a URL. In this scenario, Pulumi creates a temporary project, deploys the infrastructure, and then deletes the temporary project files, leaving only the state of the stack. This is particularly useful for rapid prototyping or deploying standardized infrastructure patterns.
Detailed Flag Analysis and Operational Impact
The pulumi up command includes a wide array of flags that modify its behavior, allowing users to tune the deployment process for safety, speed, or specificity.
Approval and Automation
In a standard workflow, pulumi up provides a preview of the changes and asks the user for confirmation before proceeding. This serves as a safety gate, preventing accidental deletions or costly resource escalations.
pulumi up --yesorpulumi up -y
This flag skips the confirmation prompt. It automatically approves and performs the update after the preview is generated. This is critical for Continuous Integration and Continuous Deployment (CI/CD) pipelines where no human is present to type "yes" in a terminal.
Stack Targeting
Pulumi organizes infrastructure into stacks, which are isolated instances of a Pulumi program (e.g., dev, staging, prod).
pulumi up --stack {{stack}}orpulumi up -s [stack]
This allows the user to deploy changes to a specific stack regardless of the currently selected stack in the environment. This prevents the risk of accidentally deploying development code into a production environment.
Resource and Output Control
Users can control the verbosity of the command and the scope of the update.
pulumi up --suppress-outputs
This prevents the display of stack outputs after the update. Stack outputs are the values returned by the program (such as a public IP address). Suppressing them is useful in logs to reduce noise or protect sensitive information.pulumi up --target [urn]
This limits the update to specific resources identified by their Uniform Resource Name (URN). Instead of updating the entire stack, Pulumi only applies changes to the targeted resource and its dependencies. This is essential for fixing a single failing resource in a massive infrastructure.pulumi up --replace urn
This forces the replacement of a specific resource. Even if the goal state suggests an update,--replacetells Pulumi to destroy the resource and create a new one from scratch.
Execution and Error Handling
The performance and reliability of the deployment can be adjusted via execution flags.
pulumi up --continue-on-error
This instructs Pulumi to continue updating other resources even if an error is encountered during the deployment of one resource. This prevents a single non-critical failure from blocking the deployment of the entire infrastructure.pulumi up --parallel norpulumi up -p n
This sets the parallelism level, determining how many resources Pulumi attempts to create or update simultaneously. Increasing this value can speed up the deployment of large-scale infrastructure.pulumi up --refresh
This forces Pulumi to refresh the current state by querying the cloud provider before calculating the diff. This ensures that any manual changes made in the cloud console are accounted for, preventing state drift.pulumi up --skip-previeworpulumi up -f
This skips the preview step entirely and proceeds directly to the update.
Debugging and Diffing
For complex infrastructure, visibility into the "why" and "how" of a change is mandatory.
pulumi up --diff
This displays a detailed diff of the changes. It provides a more granular view of exactly which properties of a resource are being modified.pulumi up --attach-debugger stringArray[=program]
This enables the ability to attach a debugger to the program and source-based plugins during execution. This is a high-level tool for developers to step through their infrastructure code to find logic errors.
Practical Application: The UpCloud Workflow
To understand how pulumi up functions in a real-world environment, consider the deployment of a server on UpCloud. This process involves several preparatory steps before the deployment command is executed.
First, the Pulumi CLI must be installed. On Linux, this is achieved via the official installation script:
curl -fsSL https://get.pulumi.com | sh
After installation, the user verifies the installation with:
pulumi version
Before executing pulumi up, state management must be configured. Pulumi state tracks the resources deployed, their configurations, and their relationships. For those starting a new project, the pulumi new command is used to create the project structure and install dependencies. For example:
mkdir pulumi-demo && cd pulumi-demo
pulumi new serverless-aws-typescript
In a Python-based UpCloud project, Pulumi creates a virtual environment to avoid interfering with the system's Python installation. To activate this environment, the user runs:
source venv/bin/activate
Once the environment is active and the UpCloud provider is installed, the user defines the infrastructure in a file such as __main__.py.
Modifying Infrastructure
Consider a scenario where a server is initially deployed with a plan of 1xCPU-1GB. To increase the resources, the user modifies the code:
```python
Create an UpCloud server
server = upcloud.Server("server",
title= "Pulumi Server",
hostname="pulumi.example.com",
zone="de-fra1",
plan="2xCPU-2GB", # Changed from 1xCPU-1GB
firewall=True,
...
```
After saving the file, the user executes:
pulumi up
Pulumi performs the following sequence:
1. It reads the modified __main__.py.
2. It compares the new plan (2xCPU-2GB) with the existing state (1xCPU-1GB).
3. It presents a preview. The symbol ~ is used to indicate that a resource will be updated rather than created.
4. Upon the user selecting "yes", the update is applied.
The output of the command provides a clear summary of the operation:
text
Updating (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/username...
Type Name Status Info
pulumi:pulumi:Stack upcloud-dev
~ └─ upcloud:index:Server server updated (63s) [diff: ~plan]
Outputs:
hostname : "pulumi.example.com"
location : "de-fra1"
public_ip: "5.22.213.250"
server_id: "0077945c-b262-4dd5-981f-b4c9575e9c48"
Resources:
~ 1 updated
2 unchanged
Duration: 1m7s
One critical nuance of the pulumi up operation in UpCloud is that while changing the plan modifies the CPU and RAM resources, it does not automatically resize the disk. This illustrates that pulumi up is bound by the capabilities of the underlying cloud provider's API.
Comparative Analysis of Deployment Commands
| Command | Primary Purpose | Key Characteristic | Use Case |
|---|---|---|---|
pulumi up |
Create or update resources | Incremental, state-aware | Daily infrastructure updates |
pulumi up --yes |
Automated deployment | No manual confirmation | CI/CD pipelines |
pulumi up --stack |
Target specific environment | Environment isolation | Switching between dev and prod |
pulumi up --target |
Update specific resource | Granular control | Fixing single-resource errors |
pulumi up --replace |
Force recreate | Destructive update | Forcing a clean resource state |
Analysis of Infrastructure State and Convergence
The effectiveness of pulumi up relies entirely on the concept of convergence. Convergence is the process of moving the actual state of the world toward the desired state defined in the code.
When pulumi up is executed, it does not simply run a script; it performs a reconciliation loop. The current state is the "Actual State," and the code is the "Desired State." The gap between these two is the "Delta." The command's primary function is to eliminate this delta.
The transactional nature of the state snapshot is what enables this. Every time pulumi up completes, it updates the state file. This file acts as the single source of truth regarding what Pulumi believes is deployed. If a user were to delete a server manually via the cloud console, the state file would still show the server as existing. This is where the --refresh flag becomes critical; it synchronizes the state file with the actual cloud reality before calculating the diff.
The impact of this model is a significant reduction in "configuration drift." Configuration drift occurs when the actual state of infrastructure deviates from the documented or coded state. By consistently using pulumi up as the sole mechanism for change, organizations can ensure that their infrastructure remains consistent, reproducible, and auditable.
Furthermore, the use of a resource graph allows Pulumi to handle complex dependencies that would be difficult to manage manually. For example, if a database must be created before an application server can be deployed, Pulumi identifies this dependency in the graph and ensures the database is fully provisioned before initiating the server's creation. If an error occurs during the database creation, pulumi up will stop the process (unless --continue-on-error is specified), preventing the application server from being deployed in a broken state.
Summary of Command Options and Logic
To ensure absolute clarity on the logic applied during the pulumi up execution, the following mapping of flags to outcomes is provided.
- For automation: use
---yes. - For environment control: use
--stack. - For output management: use
--suppress-outputs. - For fault tolerance: use
--continue-on-error. - For precision updates: use
--target. - For forced renewal: use
--replace. - For synchronization: use
--refresh. - For speed: use
--parallel. - For visibility: use
--diff. - For debugging: use
--attach-debugger.