0.1.0 • Published 7 months ago

@ediri/backstage-scaffolder-backend-pulumi-og v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
7 months ago

Pulumi Scaffolder Backend Module

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/plugins/scaffolder.ts
import {
    pulumiNewAction,
    pulumiUpAction
} from '@pulumi/backstage-scaffolder-backend-pulumi';

const actions = [
    pulumiNewAction(),
    pulumiUpAction(),
    ...createBuiltinActions({
        integrations,
        catalogClient,
        config: env.config,
        reader: env.reader,
    })
]

return await createRouter({
    actions,
    logger: env.logger,
    config: env.config,
    database: env.database,
    reader: env.reader,
    catalogClient,
    identity: env.identity,
    permissions: env.permissions,
});

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

InputDescriptionTypeRequired
stackThe Pulumi stack to usestringYes
organizationThe Pulumi organization to use for the Pulumi commandsstringYes
nameThe Pulumi project name to usestringYes
templateThe Pulumi template to use, this can be a built-in template or a URL to a templatestringYes
descriptionThe Pulumi project description to usestringYes
configThe Pulumi project config to useobjectNo
secretConfigThe Pulumi project secret config to useobjectNo
argsThe Pulumi command arguments to runarray(string)No
folderThe folder to run Pulumi instringYes
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

InputDescriptionTypeRequired
stackThe Pulumi stack to usestringYes
organizationThe Pulumi organization to use for the Pulumi commandsstringYes
nameThe Pulumi project name to usestringYes
deploymentThis flag indicates that Pulumi Deployment will be usedbooleanYes
configThe Pulumi project config to useobjectNo
secretConfigThe Pulumi project secret config to useobjectNo
outputsThe Pulumi project outputs to returnarray(string)No
repoUrlThe Pulumi project repo URL to use, when using Pulumi DeploymentstringNo
repoBranchThe Pulumi project repo branch to use, when using Pulumi DeploymentstringNo
repoProjectPathThe Pulumi project repo path to use, when using Pulumi DeploymentstringNo
providerCredentialsFromEnvThe Pulumi project provider credentials to usearray(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 }}