# Pulumi (/docs/postgres/iac/pulumi)

Location: Postgres > Infrastructure as Code > Pulumi

Use [Pulumi](https://www.pulumi.com/) with the Prisma Postgres Terraform provider through the Pulumi Terraform bridge.

This is the currently supported path for managing Prisma Postgres from Pulumi.

Conceptual model [#conceptual-model]

Pulumi lets you define infrastructure with a general-purpose language, but still deploys declaratively:

* You write resource code in TypeScript.
* Pulumi builds a dependency graph and previews changes (`pulumi preview`/`pulumi up`).
* Stack state tracks what exists, including secret outputs.

In this guide, Pulumi consumes the Prisma Terraform provider through a generated SDK, so you get typed resources while reusing the same provider capabilities.

When to use Pulumi [#when-to-use-pulumi]

Pulumi is a strong fit when:

* You want infrastructure and application code in the same language.
* You prefer typed APIs and IDE support over HCL.
* You already use Pulumi stacks for environment management.

Prerequisites [#prerequisites]

* [Pulumi CLI](https://www.pulumi.com/docs/iac/download-install/)
* A Pulumi TypeScript project (create one with `pulumi new typescript`)
* A Prisma service token (see [Management API authentication docs](/management-api/authentication#service-tokens))

1. Optional: use Bun for dependency installs [#1-optional-use-bun-for-dependency-installs]

If you want Pulumi to use Bun in this project, set this in `Pulumi.yaml`:

```yaml file=Pulumi.yaml
runtime:
  name: nodejs
  options:
    packagemanager: bun
```

2. Add the Prisma Postgres provider package [#2-add-the-prisma-postgres-provider-package]

From your Pulumi project directory, run:

```bash
pulumi package add terraform-provider registry.terraform.io/prisma/prisma-postgres 0.2.0
```

This command:

* Generates a local SDK in `sdks/prisma-postgres`
* Adds `packages.prisma-postgres` metadata to `Pulumi.yaml`
* Adds `@pulumi/prisma-postgres` to `package.json` as a local file dependency

Alternative: local provider binary [#alternative-local-provider-binary]

If you are developing the provider locally, you can also add it from a local binary path:

```bash
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.

3. Configure authentication [#3-configure-authentication]

Use one of these methods:

Option A: environment variable [#option-a-environment-variable]

```bash
export PRISMA_SERVICE_TOKEN="prsc_your_token_here"
```

Option B: Pulumi config secret [#option-b-pulumi-config-secret]

```bash
pulumi config set prisma-postgres:serviceToken "prsc_your_token_here" --secret
```

4. Define resources in index.ts [#4-define-resources-in-indexts]

```ts file=index.ts
import * 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;
```

5. Deploy [#5-deploy]

```bash
pulumi up
```

To read secret outputs:

```bash
pulumi stack output connectionString --show-secrets
pulumi stack output directUrl --show-secrets
```

6. Clean up [#6-clean-up]

```bash
pulumi destroy
```

Production notes [#production-notes]

* Store Pulumi state in a managed backend (Pulumi Cloud, S3-compatible backend, etc.).
* Keep service tokens in Pulumi secrets/config or your secret manager, never in source files.
* The generated SDK is a local dependency (`file:sdks/prisma-postgres`), so keep it available in CI/CD.
* Pin the Terraform provider version in `pulumi package add` for reproducible deployments.

Common troubleshooting [#common-troubleshooting]

Package add failed [#package-add-failed]

Confirm you're running the command inside a Pulumi project directory containing `Pulumi.yaml`.

Missing credentials [#missing-credentials]

If provider auth fails, verify either `PRISMA_SERVICE_TOKEN` is set or `prisma-postgres:serviceToken` is configured for the current stack.

SDK not found in CI [#sdk-not-found-in-ci]

If CI cannot resolve `@pulumi/prisma-postgres`, make sure `sdks/prisma-postgres` exists in the workspace or rerun `pulumi package add` during CI setup.

References [#references]

* [Pulumi package add](https://www.pulumi.com/docs/iac/cli/commands/pulumi_package_add/)
* [Using any Terraform provider in Pulumi](https://www.pulumi.com/docs/iac/concepts/providers/any-terraform-provider/)
* [Prisma Postgres provider on Terraform Registry](https://registry.terraform.io/providers/prisma/prisma-postgres/latest)
* [Prisma Postgres Terraform provider source](https://github.com/prisma/terraform-provider-prisma-postgres)

## Related pages

- [`Alchemy`](https://www.prisma.io/docs/postgres/iac/alchemy): Provision and manage Prisma Postgres projects, databases, and connections with Alchemy.
- [`Terraform`](https://www.prisma.io/docs/postgres/iac/terraform): Provision and manage Prisma Postgres projects, databases, and connections using Terraform.