Skip to content

Connecting pipelines ​

Most organizations manage more than one IaC pipeline. With Pulumi Delivery, you can connect them through artifacts and pipeline sources.

Passing artifacts between pipelines ​

In this example, an upstream pipeline publishes an Artifact from a pipeline stage:

typescript
import * as delivery from "@pulumi/delivery";

const repo = new delivery.GitHubSource("repo", {
    repository: "acme/platform",
    branch: "main",
    trigger: true,
});

const pipeline = new delivery.Pipeline("platform");

const prod = new delivery.Stage("prod", { pipeline });

const cluster = new delivery.Stacks("cluster", {
    stage: prod,
    stacks: { cluster: { stack: "platform-cluster/prod", source: repo, directory: "cluster" } },
});

new delivery.Artifact("clusterEndpoint", {
    stage: prod,
    value: cluster.outputs.apply((o) => o["cluster"]["endpoint"]),
});

Downstream pipelines can read these artifacts with PipelineSource:

typescript
import * as delivery from "@pulumi/delivery";

const repo = new delivery.GitHubSource("repo", {
    repository: "acme/shop",
    branch: "main",
    trigger: { paths: ["app/**", "delivery/**"] },
});

const pipeline = new delivery.Pipeline("shop");

const platform = new delivery.PipelineSource("platform", {
    pipeline: "platform-delivery/main",
    stage: "prod",
    trigger: true,
});

const dev = new delivery.Stage("dev", { pipeline });

new delivery.Stacks("app", {
    stage: dev,
    stacks: {
        app: {
            stack: "shop-app/dev",
            source: repo,
            directory: "app",
            config: { clusterEndpoint: platform.artifacts.apply((a) => String(a["clusterEndpoint"])) },
        },
    },
});

With trigger: true on the PipelineSource, the downstream pipeline starts a run whenever the upstream stage deploys a new release.

Pipelines must belong to the same Pulumi organization, and the identity of each downstream pipeline must have read access to the upstream pipeline stack. This is because downstream runs read upstream artifacts as the downstream pipeline's identity, not as the person who started the run. Registration grants this access to the service principal Delivery generates for a pipeline; a service principal you manage, or a team, needs Stack Read on the upstream pipeline stack granted to it. If the artifact is secret, pass it in environment instead of config.

Patterns for monorepos ​

It's also common to keep several pipelines in one repository. Give each pipeline its own program directory and stack, and set its source's trigger paths so it runs only when its own files change.

typescript
// delivery/shop/index.ts
import * as delivery from "@pulumi/delivery";

new delivery.GitHubSource("repo", {
    repository: "acme/monorepo",
    branch: "main",
    trigger: { paths: ["shop/**", "delivery/shop/**"] },
});

new delivery.Pipeline("shop");

Next steps ​

Content from the official Pulumi documentation (github.com/pulumi/docs).