Pulumi logo

Backstage Pulumi Plugin

Created by @pulumicorp

Pulumi is an open source infrastructure as code tool. It lets you implement your desired state infrastructure with regular programming languages.

The Backstage Pulumi plugin brings infrastructure data associated with your Pulumi stacks to your Developer Portal. The plugin can pull deployment information from a Pulumi Cloud.

In this guide you’ll find:

A screenshot of the Pulumi plugin.

Installation Instructions

These instructions apply to self-hosted Backstage only.

Install the plugin.

Copy
cd packages/app
yarn add @pulumi/backstage-plugin-pulumi

Add the plugin API to your Backstage app.

Copy
// packages/app/src/components/catalog/EntityPage.tsx
import {
  isPulumiAvailable,
  EntityPulumiCard,
  EntityPulumiMetdataCard,
  PulumiComponent
} from '@pulumi/backstage-plugin-pulumi';

// add new Pulumi tab to the service component page when available
const pulumiContent = (
    <EntitySwitch>
        <EntitySwitch.Case if={isPulumiAvailable}>
            <PulumiComponent/>
        </EntitySwitch.Case>
    </EntitySwitch>
);

const overviewContent = (
  <EntityLayout>
    ...
    <EntitySwitch>
        <EntitySwitch.Case if={isPulumiAvailable}>
            <Grid item md={6}>
                <EntityPulumiCard variant="gridItem"/>
            </Grid>
        </EntitySwitch.Case>
    </EntitySwitch>
    ...
  </EntityLayout>
)

const serviceEntityPage = (
  <EntityLayout>
    ...
    <EntityLayout.Route path="/pulumi" title="Pulumi" if={isPulumiAvailable}>
        {pulumiContent}
    </EntityLayout.Route>
    ...
  </EntityLayout>
);

Add proxy configuration to your Backstage app’s config. A Pulumi access token is required. See how to get a Pulumi access token below.

Copy
// 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

Add Pulumi plugin annotation to your component’s config. ()

Copy
// catalog-info.yaml
metadata:
  annotations:
      pulumi.com/project-slug: [ Pulumi Cloud Name: org/stackname/stack ]

Add Pulumi plugin annotation to your system entity. ()

Copy
// catalog-info.yaml
metadata:
  annotations:
      pulumi.com/orga-slug: <Pulumi Cloud: org>

Things to Know

Your Backstage app’s backend connects to your Pulumi Cloud organization using the Pulumi Cloud Rest API. A Pulumi Access Token is required. This token can be obtained from a system environment variable (ex. PULUMI_ACCESS_TOKEN). This can be a personal access token, but is preferrably a team or organization access token.

See the respective documentation to create a Pulumi access token.

Set up Backstage in minutes with Roadie