Skip to content

pulumi/pulumi-backstage-plugin

Pulumi

This repository contains plugins and modules for Backstage to support Pulumi.

Note

This is a work in progress and happy to receive feedback and contributions.

Important

The Pulumi Scaffolder Backend Module and the Pulumi Catalog Backend Module in version > v0.6.0 are now supporting the new Backstage Backend System.

This repository contains the following Backstage plugins and modules:

Pulumi Scaffolder Backend Module

Requirements

Pulumi CLI

You need to have the Pulumi CLI installed on the Backstage server.

If you use the Backstage Dockerfile, add following lines before the USER node line:

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt-get install -y --no-install-recommends curl ca-certificates

and add following lines after the USER node line:

RUN <<EOF
## Install pulumi and set to PATH
curl -fsSL https://get.pulumi.com | sh
EOF

ENV PATH="/node/.pulumi/bin:${PATH}"

This will install the latest Pulumi CLI to your Backstage container.

Pulumi Personal Access Token (PAT)

To authenticate to the Pulumi cloud service, you need to provide additionally the Pulumi Personal Access Token via the environment variable `PULUMI_ACCESS_TOKEN``

Programming languages runtimes

If you're not going to use the Pulumi Deployment service, you need to be sure that all the programming language runtimes are installed on your Backstage service

Getting Started

You need to configure the action in your backend:

From your Backstage root directory

# From your Backstage root directory
yarn add --cwd packages/backend @pulumi/backstage-scaffolder-backend-pulumi

Configure the action (you can check the docs to see all options):

// packages/backend/src/index.ts
const backend = createBackend();
backend.add(import('@pulumi/backstage-scaffolder-backend-pulumi'));

PULUMI_ACCESS_TOKEN

You need to set the PULUMI_ACCESS_TOKEN environment variable to be able to use the Pulumi action.

Pulumi New Action

The Pulumi New Action is a custom action that allows you to create a new Pulumi project from a template.

pulumi:new

Input Description Type Required
stack The Pulumi stack to use string Yes
organization The Pulumi organization to use for the Pulumi commands string Yes
name The Pulumi project name to use string Yes
template The Pulumi template to use, this can be a built-in template or a URL to a template string Yes
description The Pulumi project description to use string Yes
config The Pulumi project config to use object No
secretConfig The Pulumi project secret config to use object No
args The Pulumi command arguments to run array(string) No
folder The folder to run Pulumi in string Yes
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: kubernetes-template
  title: Kubernetes Cluster
  description: |
    A template for creating a new Kubernetes Cluster.
  tags:
  - pulumi
  - kubernetes
spec:
  steps:
  - id: pulumi-new-component
    name: Cookie cut the component Pulumi project
    action: pulumi:new
    input:
      name: "${{ parameters.component_id }}-infrastructure"
      description: ${{ parameters.description | dump }}
      organization: ediri
      stack: ${{ parameters.stack }}
      template: "https://github.com/my-silly-organisation/microservice-civo/tree/main/infrastructure-${{ parameters.cloud }}-${{ parameters.language }}"
      config:
        "node:node_count": "${{ parameters.nodeCount }}"
      folder: .

Pulumi Up Action

The Pulumi Up Action is a custom action that allows you to run the pulumi up command.

pulumi:up

Input Description Type Required
stack The Pulumi stack to use string Yes
organization The Pulumi organization to use for the Pulumi commands string Yes
name The Pulumi project name to use string Yes
deployment This flag indicates that Pulumi Deployment will be used boolean Yes
config The Pulumi project config to use object No
secretConfig The Pulumi project secret config to use object No
outputs The Pulumi project outputs to return array(string) No
repoUrl The Pulumi project repo URL to use, when using Pulumi Deployment string No
repoBranch The Pulumi project repo branch to use, when using Pulumi Deployment string No
repoProjectPath The Pulumi project repo path to use, when using Pulumi Deployment string No
providerCredentialsFromEnv The Pulumi project provider credentials to use array(string) No
preRunCommands The Pulumi project pre-run commands to run array(string) No
suppressProgress Suppress progress output boolean No
environments ESC environments to add to the stack array(string) No

The action offers also Pulumi deployment support, to use it you need to set the deployment input to true. If you did not set any config or secretConfig, during the pulumi:new action, you need to set them here. If you have any provider related credentials, you need to set the providerCredentialsFromEnv input.

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: kubernetes-template
  title: Kubernetes Cluster
  description: |
    A template for creating a new Kubernetes Cluster.
  tags:
  - pulumi
  - kubernetes
spec:
  steps:
  - id: pulumi-deploy-infrastructure
    name: Deploy the infrastructure using Pulumi CLI
    action: pulumi:up
    input:
      deployment: false
      name: "${{ parameters.component_id }}-infrastructure"
      repoUrl: "https://github.com/${{ (parameters.repoUrl | parseRepoUrl)['owner'] }}/${{ (parameters.repoUrl | parseRepoUrl)['repo'] }}"
      repoProjectPath: .
      organization: ediri
      outputs:
      - kubeconfig
      - ClusterId
      stack: ${{ parameters.stack }}

Note

If you run pulumi:up via CLI and with a local Pulumi template you may need to install the required dependencies for the Pulumi SDK to work. This can now be done via the preRunCommands input. For example for a node based Pulumi project you need to run npm install before running pulumi up.

Pulumi Preview Action

The Pulumi Preview Action allows you to preview changes without deploying.

pulumi:preview

Input Description Type Required
stack The Pulumi stack to use string Yes
organization The Pulumi organization to use string Yes
name The Pulumi project name to use string Yes
config The Pulumi project config to use object No
secretConfig The Pulumi project secret config to use object No
repoProjectPath The Pulumi project repo path to use string No
preRunCommands Commands to execute before running preview array(string) No
environments ESC environments to add to the stack array(string) No
expectNoChanges Return an error if any changes are proposed boolean No
refresh Refresh the stack state before preview (default: true) boolean No

Output: changeSummary - Summary of proposed changes by operation type.

steps:
  - id: pulumi-preview
    name: Preview infrastructure changes
    action: pulumi:preview
    input:
      name: my-infrastructure
      organization: my-org
      stack: dev
      repoProjectPath: .
      environments:
        - my-org/my-esc-env

Pulumi Destroy Action

The Pulumi Destroy Action allows you to destroy stack resources. Requires explicit confirmation.

pulumi:destroy

Input Description Type Required
stack The Pulumi stack to use string Yes
organization The Pulumi organization to use string Yes
name The Pulumi project name to use string Yes
confirm Safety flag - must be set to true to execute destroy boolean Yes
repoProjectPath The Pulumi project repo path to use string No
preRunCommands Commands to execute before running destroy array(string) No
environments ESC environments to add to the stack array(string) No
removeStack Remove the stack after destroying resources boolean No
targetUrns Specific resource URNs to destroy array(string) No

Output: summary - Summary of destroyed resources by operation type.

steps:
  - id: pulumi-destroy
    name: Destroy infrastructure
    action: pulumi:destroy
    input:
      name: my-infrastructure
      organization: my-org
      stack: dev
      confirm: true  # Required safety flag
      removeStack: true  # Optionally remove the stack after destroy

Pulumi Deployment Config Action

The Pulumi Deployment Config Action configures Pulumi Deployments settings via the Pulumi Cloud REST API.

pulumi:deployment:config

Input Description Type Required
organization The Pulumi organization string Yes
project The Pulumi project name string Yes
stack The Pulumi stack name string Yes
sourceContext Git source configuration object No
operationContext Operation context (env vars, OIDC, options) object No
github GitHub integration settings object No
cacheOptions Cache options for deployments object No
executorContext Executor context configuration object No

Outputs:

  • settingsUrl - URL to view deployment settings in Pulumi Cloud
  • configured - Whether settings were successfully configured
steps:
  - id: configure-deployment
    name: Configure Pulumi Deployments
    action: pulumi:deployment:config
    input:
      organization: my-org
      project: my-project
      stack: dev
      sourceContext:
        git:
          repoUrl: https://github.com/my-org/my-repo
          branch: main
          repoDir: infrastructure
      operationContext:
        preRunCommands:
          - npm install
        oidc:
          aws:
            roleArn: arn:aws:iam::123456789:role/pulumi-deploy
      github:
        repository: my-org/my-repo
        deployCommits: true
        previewPullRequests: true

Pulumi Deployment Run Action

The Pulumi Deployment Run Action triggers a Pulumi Deployment via the Pulumi Cloud REST API.

pulumi:deployment:run

Input Description Type Required
organization The Pulumi organization string Yes
project The Pulumi project name string Yes
stack The Pulumi stack name string Yes
operation The operation to run (update, preview, refresh, destroy, detect-drift) string Yes
inheritSettings Inherit deployment settings from stack configuration (default: true) boolean No
operationContext Override operation context settings object No
sourceContext Override source context settings object No

Outputs:

  • deploymentId - The ID of the triggered deployment
  • deploymentUrl - URL to view the deployment in Pulumi Cloud
  • version - The deployment version number
steps:
  - id: trigger-deployment
    name: Trigger Pulumi Deployment
    action: pulumi:deployment:run
    input:
      organization: my-org
      project: my-project
      stack: prod
      operation: update
      inheritSettings: true

Pulumi Plugin

  • Display relevant Pulumi information about an entity within Backstage, such as the Pulumi stack, organization, project name, and project description.
  • Show stack outputs directly in the Pulumi card (e.g., URLs, resource IDs, connection strings).
  • Show the Pulumi activity view for an entity within Backstage.
  • Support for multiple stacks and organizations with tabbed UI.
  • Pulumi Dashboard: A standalone dashboard page showing organization-wide metrics, recent stack updates, deployments, and resource trends.

Requirements

  • Setup of the Pulumi plugin for Backstage requires a Pulumi Organization admin to generate a Pulumi access token for the Backstage application.

Feature Overview

Pulumi Card (Component Overview)

Pulumi Card (System Overview)

Pulumi Activity View

Multiple Stacks View

When an entity has multiple stacks configured, they are displayed as tabs in the UI:

Pulumi Dashboard

The Pulumi Dashboard provides an organization-wide view of your Pulumi infrastructure:

  • Organization Selector: Switch between Pulumi organizations you have access to
  • Stats Cards: View counts for Members, Stacks, ESC Environments, and Resources
  • Latest Stack Updates: See recent stack activity with status, timing, and resource changes
  • Latest Deployments: Monitor recent Pulumi Deployments with status and links
  • Resource Trends: Interactive chart showing resource count over time with configurable time ranges and CSV export

Support

If you need any help with this plugin, feel free to reach out to me!

Integration Walk-through

Install the plugin

The file paths mentioned in the following steps are relative to your app's root directory — for example, the directory created by following the Getting Started guide and creating your app with npx @backstage/create-app.

First, install the Pulumi plugin via a CLI:

# From your Backstage root directory
yarn add --cwd packages/app @pulumi/backstage-plugin-pulumi

Next, add the plugin to EntityPage.tsx in packages/app/src/components/catalog by adding the following code snippets.

Add the following imports to the top of the file:

import {
    isPulumiAvailable,
    EntityPulumiCard,
    EntityPulumiMetdataCard,
    PulumiComponent,
    PulumiDashboardPage,
} from '@pulumi/backstage-plugin-pulumi';

Then create a new constant for the Pulumi Component:

const pulumiContent = (
    <EntitySwitch>
        <EntitySwitch.Case if={isPulumiAvailable}>
            <PulumiComponent/>
        </EntitySwitch.Case>
    </EntitySwitch>
);

Find const overviewContent in EntityPage.tsx, and add the following snippet inside the outermost Grid defined there, just before the closing </Grid> tag:

<EntitySwitch>
    <EntitySwitch.Case if={isPulumiAvailable}>
        <Grid item md={6}>
            <EntityPulumiCard variant="gridItem"/>
        </Grid>
    </EntitySwitch.Case>
</EntitySwitch>

Now find the serviceEntityPage constant in EntityPage.tsx, and add the following snippet inside:

<EntityLayout.Route path="/pulumi" title="Pulumi" if={isPulumiAvailable}>
    {pulumiContent}
</EntityLayout.Route>

Add the Pulumi Dashboard Page (Optional)

To add the standalone Pulumi Dashboard page, add a route in your App.tsx:

import { PulumiDashboardPage } from '@pulumi/backstage-plugin-pulumi';

// In your routes
<Route path="/pulumi" element={<PulumiDashboardPage />} />

You can also add a sidebar navigation item in your Root.tsx:

<SidebarItem icon={YourIcon} to="pulumi" text="Pulumi" />

Lastly, find the systemPage constant in EntityPage.tsx, and add the following snippet inside after the closing </Grid> tag of the <EntityAboutCard variant="gridItem" />:

  <EntitySwitch>
    <EntitySwitch.Case if={isPulumiAvailable}>
        <Grid item md={6}>
            <EntityPulumiMetdataCard/>
        </Grid>
    </EntitySwitch.Case>
</EntitySwitch>

Configure the plugin

First, annotate your component/resource entity with the following:

annotations:
  pulumi.com/project-slug: <org/project/stack>

You can also specify multiple stacks using comma-separated values:

annotations:
  # Multiple stacks - displays as tabs in the UI
  pulumi.com/project-slug: acme/web-app/prod,acme/web-app/staging,acme/api/prod

And your system entity with the following:

annotations:
  pulumi.com/orga-slug: <org>

You can also specify multiple organizations using comma-separated values:

annotations:
  # Multiple organizations - displays as tabs in the UI
  pulumi.com/orga-slug: acme,widgets-inc

Next, provide the API token that the client will use to make requests to the Pulumi Cloud API.

Add the proxy configuration in app-config.yaml:

proxy:
  '/pulumi':
    target: 'https://api.pulumi.com/api'
    changeOrigin: true
    headers:
      Authorization: token ${PULUMI_ACCESS_TOKEN}
      Accept: application/vnd.pulumi+8
      Content-Type: application/json

Then, start the backend, passing the Pulumi Access Token as an environment variable:

export PULUMI_ACCESS_TOKEN='<PULUMI_ACCESS_TOKEN>' 
yarn start

This will proxy the request by adding an Authorization header with the provided token.

How to Uninstall

  1. Remove any configuration added in Backstage yaml files, such as the proxy configuration in app-config.yaml and the integration key in an entity's annotations.
  2. Remove the added code snippets from EntityPage.tsx
  3. Remove the plugin package:
# From your Backstage root directory
yarn remove --cwd packages/app @pulumi/backstage-plugin-pulumi

New Frontend System

This plugin supports the new Backstage frontend system. Follow these steps to use it in an application that supports the new frontend system.

Package Detection

Once you install the @pulumi/backstage-plugin-pulumi package, you can choose how the package should be detected by the app. The package can be automatically discovered when the feature discovery config is set, or it can be manually enabled via code.

Via config Via code
# app-config.yaml
app:
  # Enable package discovery for all plugins
  packages: 'all'
---
app:
  # Enable package discovery only for Pulumi
  packages:
    include:
      - '@pulumi/backstage-plugin-pulumi'
      
// packages/app/src/App.tsx
import { createApp } from '@backstage/frontend-defaults';
import pulumiPlugin from '@pulumi/backstage-plugin-pulumi/alpha';
const app = createApp({
features: [
// ...other plugins
pulumiPlugin,
],
});

Extensions Configuration

The plugin installs the following extensions:

Extension Kind Description
api:pulumi API Pulumi API client for communicating with Pulumi Cloud
page:pulumi Page Standalone Pulumi Dashboard page at /pulumi
entity-card:pulumi/stack Entity Card Shows stack information, outputs, and metadata
entity-card:pulumi/metadata Entity Card Shows organization metadata and resources by provider
entity-content:pulumi/activity Entity Content Shows Pulumi activity/updates in an entity tab

You can configure these extensions in your app-config.yaml:

# app-config.yaml
app:
  extensions:
    # Disable the Pulumi stack card
    - entity-card:pulumi/stack: false

    # Disable the Pulumi metadata card
    - entity-card:pulumi/metadata: false

    # Disable the Pulumi entity content tab
    - entity-content:pulumi/activity: false

    # Customize the Pulumi entity content path and title
    - entity-content:pulumi/activity:
        config:
          path: '/infrastructure'
          title: 'Infrastructure'

    # Customize the Pulumi dashboard page path
    - page:pulumi:
        config:
          path: '/infrastructure-dashboard'

Catalog Backend Module for Pulumi

This is an extension module to the plugin-catalog-backend plugin, providing an PulumiEntityProvider that can be used to ingest Resource entities from the Pulumi Cloud. This provider is useful if you want to import Pulumi stacks into Backstage.

Installation

The provider is not installed by default, therefore you have to add a dependency to @pulumi/plugin-catalog-backend-module-pulumi to your backend package:

# From your Backstage root directory
yarn add --cwd packages/backend @pulumi/plugin-catalog-backend-module-pulumi

Update the catalog plugin initialization in your backend to add the provider and schedule it:

//packages/backend/src/index.ts
backend.add(import('@pulumi/plugin-catalog-backend-module-pulumi/alpha'));

After this, you also have to add some configuration in your app-config that describes what you want to import for that target.

Configuration

The following configuration is an example of how a setup could look for importing stacks from Pulumi Cloud:

catalog:
  providers:
    pulumi:
      default:
        api: https://api.pulumi.com
        organization: <your organization>
        pulumiAccessToken: ${PULUMI_ACCESS_TOKEN}
        schedule:
          frequency: PT10M
          timeout: PT50M

About

Pulumi plugin for Backstage

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors