### Build Terraform Provider Source: https://github.com/supabase/terraform-provider-supabase/blob/main/CONTRIBUTING.md Builds the Terraform provider binary using the Go install command. Ensure you are in the repository directory. ```shell go install ``` -------------------------------- ### Import a supabase_settings resource Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/settings.md This example shows how to import an existing Supabase settings resource using its project reference. After import, you can manage specific settings within your Terraform configuration. ```terraform # Settings can be imported using the project reference. # # - project_ref: Found in the Supabase dashboard under Project Settings -> General, # or in the project's URL: https://supabase.com/dashboard/project/ # # On import, all setting categories (API, auth, etc.) are fetched from the API. # You can then selectively manage specific settings in your Terraform configuration. terraform import supabase_settings.production ``` -------------------------------- ### Create a supabase_settings resource Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/settings.md This example demonstrates how to configure various settings for a Supabase project, including database, network, API, authentication, and storage. It uses JSON encoding for complex settings. ```terraform resource "supabase_settings" "production" { project_ref = "mayuaycdtijbctgqbycg" database = jsonencode({ statement_timeout = "10s" }) network = jsonencode({ restrictions = [ "0.0.0.0/0", "::/0" ] }) api = jsonencode({ db_schema = "public,storage,graphql_public" db_extra_search_path = "public,extensions" max_rows = 1000 }) auth = jsonencode({ site_url = "http://localhost:3000" mailer_otp_exp = 3600 mfa_phone_otp_length = 6 sms_otp_length = 6 }) storage = jsonencode({ #fileSizeLimit is expressed in bytes (e.g., 50MB = 50 * 1024 * 1024) fileSizeLimit = 52428800 features = { imageTransformation = { enabled = true } s3Protocol = { enabled = false } } }) } ``` -------------------------------- ### Network Bans Data Source Example Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/network_bans.md Example of how to use the supabase_network_bans data source to retrieve banned IPv4 addresses for a specific project. ```terraform data "supabase_network_bans" "test" { project_ref = "mayuaycdtijbctgqbycg" } ``` -------------------------------- ### supabase_apikeys Data Source Usage Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/apikeys.md Example usage of the supabase_apikeys data source to fetch API keys for a production project. ```APIDOC ## supabase_apikeys (Data Source) ### Description API Keys data source ### Schema #### Required - `project_ref` (String) Project reference ID #### Read-Only - `anon_key` (String, Sensitive) Anonymous API key for the project - `publishable_key` (String, Sensitive) Publishable API key for the project - `secret_keys` (Attributes List, Sensitive) List of secret API keys for the project (see [below for nested schema](#nestedatt--secret_keys)) - `service_role_key` (String, Sensitive) Service role API key for the project ### Nested Schema for `secret_keys` Read-Only: - `api_key` (String, Sensitive) The secret API key value - `name` (String) Name of the secret key ### Example Usage ```terraform data "supabase_apikeys" "production" { project_ref = "mayuaycdtijbctgqbycg" } ``` ``` -------------------------------- ### Create a Supabase API Key Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/apikey.md Example of how to create a new API key for a Supabase project using the `supabase_apikey` resource. Ensure you have the project reference ID and a desired name for the key. ```terraform resource "supabase_apikey" "new" { project_ref = "mayuaycdtijbctgqbycg" name = "test" } ``` -------------------------------- ### Configure Supabase Project and Settings with Terraform Source: https://github.com/supabase/terraform-provider-supabase/blob/main/README.md This example demonstrates how to configure a Supabase project and its API settings using the Supabase Terraform provider. Ensure the SUPABASE_ACCESS_TOKEN environment variable is set or provide the access token via a file. ```hcl terraform { required_providers { supabase = { source = "supabase/supabase" version = "~> 1.0" } } } # Alternatively, you can set the env var for SUPABASE_ACCESS_TOKEN provider "supabase" { access_token = file("${path.module}/access-token") } # Define a linked project variable as user input variable "linked_project" { type = string } # Import the linked project resource import { to = supabase_project.production id = var.linked_project } resource "supabase_project" "production" { # organization_id is your organization's slug (it can be found in the Supabase Dashboard under Organization Settings > Organization Details > Organization slug) organization_id = "nknnyrtlhxudbsbuazsu" name = "tf-project" database_password = "tf-example" region = "ap-southeast-1" } # Configure api settings for the linked project resource "supabase_settings" "production" { project_ref = var.linked_project api = jsonencode({ db_schema = "public,storage,graphql_public" db_extra_search_path = "public,extensions" max_rows = 1000 }) } ``` -------------------------------- ### Basic Edge Function Creation Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/edge_function.md This example shows how to create a basic Supabase Edge Function. It requires the project reference, a unique slug, and the path to the function's entrypoint file. ```terraform resource "supabase_edge_function" "foo" { project_ref = "mayuaycdtijbctgqbycg" slug = "foo" entrypoint = "supabase/functions/foo/index.ts" } ``` -------------------------------- ### Get API Keys for a Project Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/apikeys.md Use the `supabase_apikeys` data source to retrieve API keys for a specific Supabase project by its reference ID. ```terraform data "supabase_apikeys" "production" { project_ref = "mayuaycdtijbctgqbycg" } ``` -------------------------------- ### Example Usage of supabase_edge_function_secrets Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/edge_function_secrets.md Use this resource to manage multiple secrets for your Supabase Edge Functions. Ensure you have the correct project reference ID and define your secrets with their names and values. ```terraform resource "supabase_edge_function_secrets" "example" { project_ref = "mayuaycdtijbctgqbycg" secrets = [ { name = "API_KEY" value = "your-api-key-here" }, { name = "DATABASE_URL" value = "postgresql://user:pass@localhost:5432/db" }, { name = "STRIPE_SECRET_KEY" value = "sk_test_..." } ] } ``` -------------------------------- ### Get all branches Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/branch.md Use the `supabase_branch` data source to retrieve information about all branches associated with a parent project. This requires specifying the `parent_project_ref`. ```terraform data "supabase_branch" "all" { parent_project_ref = "mayuaycdtijbctgqbycg" } ``` -------------------------------- ### Importing an Existing Edge Function Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/edge_function.md This example demonstrates how to import an existing Supabase Edge Function into your Terraform configuration. You need the project reference and the function's slug. Note that local-only fields may need manual configuration after import. ```shell # Edge functions can be imported using the project reference and the function slug, # separated by a '/'. # # - project_ref: Found in the Supabase dashboard under Project Settings -> General, # or in the project's URL: https://supabase.com/dashboard/project/ # - slug: Found in the Supabase dashboard under Edge Functions, # or in the function's URL: https://supabase.com/dashboard/project//functions/ # # Note: Local-only fields (entrypoint, import_map, static_files, local_checksum) # may not be populated by import and must be configured manually in your Terraform configuration. terraform import supabase_edge_function.example / ``` -------------------------------- ### Get Supabase Pooler Configuration Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/pooler.md Use the `supabase_pooler` data source to retrieve the connection pooler configuration for a specific project. This is useful for obtaining connection strings for different pooler modes. ```terraform data "supabase_pooler" "production" { project_ref = "mayuaycdtijbctgqbycg" } ``` -------------------------------- ### Configure Supabase Terraform Provider Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/tutorial.md Set up the Supabase provider in your Terraform configuration. Ensure your Supabase access token is stored securely, for example, in a file named 'access-token' in the current working directory. ```terraform terraform { required_providers { supabase = { source = "supabase/supabase" version = "~> 1.0" } } } provider "supabase" { access_token = file("${path.cwd}/access-token") } ``` -------------------------------- ### Create a Supabase Project Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/project.md Use this resource to create a new Supabase project. Ensure you provide all required arguments: organization_id, name, database_password, and region. The instance_size and legacy_api_keys_enabled arguments are optional. ```terraform resource "supabase_project" "test" { organization_id = "continued-brown-smelt" name = "foo" database_password = "barbaz" region = "us-east-1" instance_size = "micro" legacy_api_keys_enabled = false } ``` -------------------------------- ### Import a Supabase API Key by Name and Type Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/apikey.md Shows how to import an API key when multiple keys share the same name. In such cases, you must also provide the API key type (publishable or secret) to uniquely identify the key for import. ```shell # If multiple keys in the project share the same name, a type must also be provided. # # - api_key_type: The `type` of the target key (publishable or secret). terraform import supabase_apikey.example // ``` -------------------------------- ### Create a Supabase Project Resource Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/tutorial.md Define a Supabase project resource using the `supabase_project` resource type. Remember to replace placeholder values with your actual organization ID, desired project name, database password, and region. Sensitive fields like `database_password` should be managed securely. ```terraform # Create a project resource resource "supabase_project" "production" { organization_id = "" name = "tf-example" database_password = "" region = "ap-southeast-1" } # Retrieve project API keys (careful with sensitive data!) data "supabase_apikeys" "production" { project_ref = supabase_project.production.id } output "anon_key" { value = data.supabase_apikeys.production.anon_key sensitive = true } output "service_role_key" { value = data.supabase_apikeys.production.service_role_key sensitive = true } ``` -------------------------------- ### Import a Supabase API Key by Name Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/apikey.md Demonstrates how to import an existing API key using its project reference and name. This is useful for managing existing keys within Terraform. The project reference can be found in the Supabase dashboard or project URL. The API key name is also available in the dashboard under Project Settings -> API Keys. ```shell # API keys can be imported using the project reference and the key's name, # separated by a '/'. # # - project_ref: Found in the Supabase dashboard under Project Settings -> General, # or in the project's URL: https://supabase.com/dashboard/project/ # - api_key_name: Found in the Supabase dashboard under Project Settings -> API Keys. terraform import supabase_apikey.example / ``` -------------------------------- ### Import an Existing Supabase Project Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/project.md Projects can be imported into Terraform state using the project reference. The project reference can be found in the Supabase dashboard under Project Settings -> General or in the project's URL. ```bash # Projects can be imported using the project reference. # # - project_ref: Found in the Supabase dashboard under Project Settings -> General, # or in the project's URL: https://supabase.com/dashboard/project/ terraform import supabase_project.production ``` -------------------------------- ### Configure API Settings for a Project Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/tutorial.md Use the `supabase_settings` resource to manage project API settings. This resource is created and destroyed with its corresponding project resource, and updates are partial and idempotent. ```terraform # Configure api settings for the linked project resource "supabase_settings" "production" { project_ref = var.linked_project api = jsonencode({ db_schema = "public,storage,graphql_public" db_extra_search_path = "public,extensions" max_rows = 1000 }) } ``` -------------------------------- ### Import a Supabase API Key by ID Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/apikey.md Illustrates importing an API key using its unique UUID (ID). This method is an alternative to using the name and is particularly useful if the key's name is not unique or if you have the key's ID readily available from API responses. ```shell # Alternatively, the key's UUID can be used instead of its name. # # - api_key_id: The `id` field of the target key from the JSON output of: # supabase projects api-keys --output json --project-ref terraform import supabase_apikey.example / ``` -------------------------------- ### Run Acceptance Tests for Terraform Provider Source: https://github.com/supabase/terraform-provider-supabase/blob/main/CONTRIBUTING.md Executes the full suite of acceptance tests for the Terraform provider. Note that these tests may incur costs as they create real resources. ```shell make testacc ``` -------------------------------- ### Configure Branch Settings with Overrides Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/tutorial.md Manage settings for multiple branches by fetching all branches of a linked project and overriding specific configurations like auth site URLs. This uses the `for_each` meta-argument to apply settings to each branch. ```terraform # Fetch all branches of a linked project data "supabase_branch" "all" { parent_project_ref = var.linked_project } # Override settings for each preview branch resource "supabase_settings" "branch" { for_each = { for b in data.supabase_branch.all.branches : b.project_ref => b } project_ref = each.key api = supabase_settings.production.api auth = jsonencode({ site_url = "http://localhost:3001" }) } ``` -------------------------------- ### supabase_pooler Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/pooler.md Fetches details about the Supabase connection pooler for a specific project. ```APIDOC ## supabase_pooler (Data Source) Pooler data source ### Description This data source retrieves information about the Supabase connection pooler, including its connection strings for different modes. ### Schema #### Required - `project_ref` (String) - The reference ID of the Supabase project. #### Read-Only - `url` (Map of String) - A map where keys represent pooler modes (e.g., "read_only", "read_write") and values are their corresponding connection strings. ``` -------------------------------- ### Import Existing Supabase Project Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/tutorial.md Import an existing Supabase project into your Terraform state. This involves defining a `linked_project` variable and using the `import` block within your resource definition. Alternatively, use the `terraform import` command directly. ```terraform # Define a linked project variable as user input variable "linked_project" { type = string } import { to = supabase_project.production id = var.linked_project } # Import a project resource resource "supabase_project" "production" { organization_id = "" name = "tf-example" database_password = "" region = "ap-southeast-1" } ``` -------------------------------- ### Create a New Supabase Branch Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/branch.md Use this resource to create a new database branch. Ensure you provide the parent project reference and the desired Git branch name. ```terraform resource "supabase_branch" "new" { parent_project_ref = "mayuaycdtijbctgqbycg" git_branch = "main" } ``` -------------------------------- ### Configure the Supabase Provider Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/index.md Configures the Supabase provider, optionally setting the access token and endpoint. It is recommended to use environment variables for sensitive information like the access token. ```terraform # Configure the Supabase Provider provider "supabase" { # Recommended: Use environment variable SUPABASE_ACCESS_TOKEN # Or specify directly (not recommended for production) # access_token = "your-access-token" } ``` -------------------------------- ### Import Edge Function Secrets Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/edge_function_secrets.md Use this command to import edge function secrets. The project reference is found in your Supabase dashboard. Note that only SHA-256 digests are imported, and secrets with a SUPABASE_ prefix are excluded. After import, you must supply plaintext secret values in your Terraform configuration and run `terraform plan` to reconcile state. Ensure sensitive values are protected using a remote state backend with encryption. ```shell # Edge function secrets can be imported using the project reference. # # - project_ref: Found in the Supabase dashboard under Project Settings -> General, # or in the project's URL: https://supabase.com/dashboard/project/ # # IMPORTANT: The Supabase management API only returns SHA-256 digests of secret # values, never the plaintext. After import: # - `secret_digests` is populated with the digests returned by the API. # - `secrets[*].value` is null for every imported secret. # - Secrets with a SUPABASE_ prefix are not imported (they are reserved). # # After running this command, supply the plaintext secret values in your Terraform # configuration and run `terraform plan` to reconcile state. Terraform will show # a plan to update the secrets to match the values in your config. # # Note: Secret values are sensitive. Always use a remote state backend with # encryption to protect sensitive values stored in Terraform state. terraform import supabase_edge_function_secrets.example mayuaycdtijbctgqbycg ``` -------------------------------- ### supabase_apikey Resource Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/apikey.md Manages an API Key resource within a Supabase project. ```APIDOC ## supabase_apikey (Resource) ### Description Manages an API Key resource within a Supabase project. ### Schema #### Required - **name** (String) Name of the API key - **project_ref** (String) Project reference ID #### Optional - **description** (String) Description of the API key #### Read-Only - **api_key** (String, Sensitive) API key - **id** (String) API key identifier - **secret_jwt_template** (Attributes) Secret JWT template - **role** (String) Role of the secret JWT template - **type** (String) Type of the API key ### Import Import is supported using the following syntax: ```shell # API keys can be imported using the project reference and the key's name, separated by a '/'. # - project_ref: Found in the Supabase dashboard under Project Settings -> General, or in the project's URL: https://supabase.com/dashboard/project/ # - api_key_name: Found in the Supabase dashboard under Project Settings -> API Keys. terraform import supabase_apikey.example / # If multiple keys in the project share the same name, a type must also be provided. # - api_key_type: The `type` of the target key (publishable or secret). terraform import supabase_apikey.example // # Alternatively, the key's UUID can be used instead of its name. # - api_key_id: The `id` field of the target key from the JSON output of: supabase projects api-keys --output json --project-ref terraform import supabase_apikey.example / ``` ``` -------------------------------- ### Import an Existing Supabase Branch Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/branch.md Import an existing Supabase branch into your Terraform state. You will need the branch ID, which can be obtained using the `supabase branches list` command. ```bash # Branches can be imported using the branch ID. # # - branch_id: The UUID of the branch. Run `supabase branches list` to find it. terraform import supabase_branch.development ``` -------------------------------- ### supabase_network_bans Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/network_bans.md Fetches the network bans for a given Supabase project. ```APIDOC ## supabase_network_bans (Data Source) ### Description Provides information about network bans for a Supabase project. ### Method GET ### Endpoint `/network/bans` ### Parameters #### Query Parameters - **project_ref** (String) - Required - Project reference ID to fetch bans for. ### Response #### Success Response (200) - **banned_ipv4_addresses** (Set of String) - A set of banned IPv4 addresses. ### Request Example ```terraform data "supabase_network_bans" "test" { project_ref = "mayuaycdtijbctgqbycg" } ``` ### Response Example ```json { "banned_ipv4_addresses": ["192.168.1.1", "10.0.0.1"] } ``` ``` -------------------------------- ### supabase_branch Data Source Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/data-sources/branch.md The `supabase_branch` data source allows you to retrieve information about Supabase branches. It requires the parent project reference to fetch the branch details. ```APIDOC ## supabase_branch (Data Source) ### Description Branch data source. Allows retrieval of branch databases within a Supabase project. ### Parameters #### Required - **parent_project_ref** (String) - The reference ID of the parent Supabase project. ### Read-Only Attributes - **branches** (Set of Objects) - A set of branch databases associated with the project. - **git_branch** (String) - The name of the Git branch. - **id** (String) - The unique identifier of the branch. - **project_ref** (String) - The project reference for the branch. ``` -------------------------------- ### supabase_edge_function_secrets Resource Source: https://github.com/supabase/terraform-provider-supabase/blob/main/docs/resources/edge_function_secrets.md Defines and manages a set of secrets for a Supabase Edge Function. This resource allows you to configure multiple key-value pairs that serve as environment secrets for your edge functions. The `project_ref` uniquely identifies your Supabase project, and the `secrets` attribute is a set of objects, each containing a `name` and a sensitive `value` for the secret. ```APIDOC ## Resource: supabase_edge_function_secrets ### Description Manages multiple secrets for edge functions within a Supabase project. ### Schema #### Required - **project_ref** (String) - Project reference ID. - **secrets** (Attributes Set) - Set of secrets for edge functions. #### Nested Schema for `secrets` Required: - **name** (String) - Name of the secret. Must not start with the `SUPABASE_` prefix. - **value** (String, Sensitive) - The plaintext secret value. #### Read-Only - **id** (String) - Project identifier. - **secret_digests** (Map of String) - Map of secret name to the SHA-256 hex digest of the secret value. This is computed by the provider at plan time and updated after each apply. It is used to detect drift when a secret has been changed outside of Terraform. ### Example Usage ```terraform resource "supabase_edge_function_secrets" "example" { project_ref = "mayuaycdtijbctgqbycg" secrets = [ { name = "API_KEY" value = "your-api-key-here" }, { name = "DATABASE_URL" value = "postgresql://user:pass@localhost:5432/db" }, { name = "STRIPE_SECRET_KEY" value = "sk_test_..." } ] } ``` ``` -------------------------------- ### Add New Dependency to Terraform Provider Source: https://github.com/supabase/terraform-provider-supabase/blob/main/CONTRIBUTING.md Adds a new dependency to your Terraform provider using Go modules. This involves fetching the dependency and tidying the module files. ```shell go get github.com/author/dependency go mod tidy ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.