Skip to main content

A Pulumi package for creating and managing SupavisorNative resources.

Project description

Pulumi Native Provider for Supavisor

Supavisor is a cloud-native, multi-tenant Postgres connection pooler developed by Supabase. This Pulumi provider allows you to manage Supavisor tenants and their configurations using infrastructure as code.

This provider was generated using an upgraded pulschema and pulumi-provider-framework.

Package SDKs

Using The Provider

Change the URL in provider/cmd/provider-gen-supavisor-native/openapi.yml to your url. You'll also need to configure the provider with your Supavisor JWT secret. Set it as a secret using:

pulumi config set --secret supavisor:jwtSecret <your-jwt-secret>

The JWT secret can also be set via the SUPAVISOR_NATIVE_JWT_SECRET environment variable or passed in as any pulumi.Input such as a stack reference.

Basic Usage

Here's a basic example of creating a Supavisor tenant. The provider will use the JWT secret to sign a new auth token JWT that lasts for five minutes.

import pulumi_supavisor_native as supavisor

# Configure the provider
provider = supavisor.Provider(
    "supavisor",
    jwt_secret="supavisor-jwt-secret",
)

# Create a tenant
tenant = supavisor.tenants.Tenant(
    "supavisor-tenant",
    external_id="unique-tenant-id-for-url",
    tenant=supavisor.tenants.TenantPropertiesArgs(
        db_host="upstream-postgres-url",
        db_port="upstream-postgres-port",
        db_database="upstream-postgres-db",
        external_id="same-unique-tenant-id",
        ip_version="auto",
        enforce_ssl=False,
        upstream_ssl=False,
        require_user=True,
        auth_query="SELECT rolname, rolpassword FROM pg_authid WHERE rolname=$1;",
        users=[
            supavisor.tenants.UserArgs(
                db_password="upstream-postgres-password",
                db_user="upstream-postgres-user",
                pool_size=20,
                mode_type="transaction",
                is_manager=False,
            )
        ],
    )
)

Resource Types

The provider currently supports the following resource types:

  • supavisor:tenants:Tenant: Manages Supavisor tenants
  • supavisor:Provider: Configures the Supavisor provider

Tenant Configuration Options

When creating a tenant, you can configure the following options:

Required Fields

  • external_id: Unique identifier for the tenant
  • db_host: Upstream Postgres host
  • db_port: Upstream Postgres port (integer)
  • db_database: Database name
  • require_user: Whether to require user authentication
  • users: List of database users (at least one user required)

Optional Fields

  • allow_list: List of CIDR addresses (defaults to ["0.0.0.0/0", "::/0"])
  • auth_query: Custom authentication query (defaults to SELECT rolname, rolpassword FROM pg_authid WHERE rolname=$1)
  • ip_version: IP version ("auto", "4", or "6")
  • enforce_ssl: Enable SSL for client connections (default: false)
  • upstream_ssl: Enable SSL for upstream connections (default: true)
  • upstream_verify: SSL verification mode (e.g., "none")
  • sni_hostname: SNI hostname for SSL connections (e.g., "your.domain.com")

User Configuration Options

Each user in the users array supports the following options:

Required Fields

  • db_user: Database username
  • db_password: Database password
  • pool_size: Number of connections in the pool (integer)

Optional Fields

  • db_user_alias: Alternative username for the connection
  • is_manager: Whether the user has manager privileges (default: false)
  • max_clients: Maximum number of allowed clients (default: 25000)
  • mode_type: Pool mode type ("transaction" or "session")
  • pool_checkout_timeout: Timeout for checking out connections from the pool (in milliseconds)
  • tenant_external_id: External ID reference for the tenant

Read-only Fields

The following fields are read-only and will be populated after resource creation:

  • id: Resource identifier
  • inserted_at: Creation timestamp
  • updated_at: Last update timestamp

Importing Existing Resources

To import an existing Supavisor tenant, use:

pulumi import supavisor:tenants:Tenant {resourceName} {external_id}

Alternatively, you can use the import option in your Pulumi program:

tenant = supavisor.tenants.Tenant(
    "existing-tenant",
    external_id="unique-tenant-id",
    tenant=supavisor.tenants.TenantPropertiesArgs(...),
    opts=pulumi.ResourceOptions(import_="unique-tenant-id")
)

Functions

The provider includes the following utility functions:

  • getTenant(external_id: string): Retrieve a tenant by its external ID

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

Apache-2.0 License

About Supavisor

Supavisor is a cloud-native, multi-tenant Postgres connection pooler that provides:

  • Connection pooling
  • Multi-tenancy support
  • Authentication and authorization
  • SSL/TLS support
  • High availability
  • Monitoring and metrics

For more information about Supavisor, visit the official repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pulumi_supavisor_native-0.0.6.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

pulumi_supavisor_native-0.0.6-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file pulumi_supavisor_native-0.0.6.tar.gz.

File metadata

  • Download URL: pulumi_supavisor_native-0.0.6.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pulumi_supavisor_native-0.0.6.tar.gz
Algorithm Hash digest
SHA256 de9c3561e6f341a4efbc175606e71b563e73688be37f5f36b9c3af686a36282e
MD5 344a9b0e614130649e6dd9ea155b0f79
BLAKE2b-256 b527e32f3ecd348764149c2971e750b8274be2022a644f44c2ab55f32ce4dce1

See more details on using hashes here.

File details

Details for the file pulumi_supavisor_native-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pulumi_supavisor_native-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4231058893a478a839ce803defadf30e832e948e67a569728d0864a11623bdde
MD5 9d63c828fc1fbbad37a793a5b798dcd0
BLAKE2b-256 eb6eaf7389a81f8140bdd574a9db4ae4f217529668a551270b09e44c529a0938

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page