apps/docs/content/docs/postgres/iac/pulumi.mdx
Use Pulumi with the Prisma Postgres Terraform provider through the Pulumi Terraform bridge.
This is the currently supported path for managing Prisma Postgres from Pulumi.
Pulumi lets you define infrastructure with a general-purpose language, but still deploys declaratively:
pulumi preview/pulumi up).In this guide, Pulumi consumes the Prisma Terraform provider through a generated SDK, so you get typed resources while reusing the same provider capabilities.
Pulumi is a strong fit when:
pulumi new typescript)If you want Pulumi to use Bun in this project, set this in Pulumi.yaml:
runtime:
name: nodejs
options:
packagemanager: bun
From your Pulumi project directory, run:
pulumi package add terraform-provider registry.terraform.io/prisma/prisma-postgres 0.2.0
This command:
sdks/prisma-postgrespackages.prisma-postgres metadata to Pulumi.yaml@pulumi/prisma-postgres to package.json as a local file dependencyIf you are developing the provider locally, you can also add it from a local binary path:
pulumi package add terraform-provider /absolute/path/to/terraform-provider-prisma-postgres
For most users, the registry form in step 2 is the recommended approach.
Use one of these methods:
export PRISMA_SERVICE_TOKEN="prsc_your_token_here"
pulumi config set prisma-postgres:serviceToken "prsc_your_token_here" --secret
index.tsimport * as pulumi from "@pulumi/pulumi";
import * as prismaPostgres from "@pulumi/prisma-postgres";
const project = new prismaPostgres.Project("project", {
name: "my-app",
});
const database = new prismaPostgres.Database("database", {
projectId: project.id,
name: "production",
region: "us-east-1",
});
const connection = new prismaPostgres.Connection("connection", {
databaseId: database.id,
name: "api-key",
});
const availableRegions = prismaPostgres.getRegionsOutput().regions.apply((regions) =>
regions.filter((r) => r.status === "available").map((r) => `${r.id} (${r.name})`)
);
export const projectId = project.id;
export const databaseId = database.id;
export const connectionString = pulumi.secret(connection.connectionString);
export const directUrl = pulumi.secret(database.directUrl);
export const regions = availableRegions;
pulumi up
To read secret outputs:
pulumi stack output connectionString --show-secrets
pulumi stack output directUrl --show-secrets
pulumi destroy
file:sdks/prisma-postgres), so keep it available in CI/CD.pulumi package add for reproducible deployments.Confirm you're running the command inside a Pulumi project directory containing Pulumi.yaml.
If provider auth fails, verify either PRISMA_SERVICE_TOKEN is set or prisma-postgres:serviceToken is configured for the current stack.
If CI cannot resolve @pulumi/prisma-postgres, make sure sdks/prisma-postgres exists in the workspace or rerun pulumi package add during CI setup.