Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement basic provider for supabase project settings #2

Merged
merged 12 commits into from
Jan 25, 2024

Conversation

sweatybridge
Copy link
Collaborator

@sweatybridge sweatybridge commented Jan 23, 2024

What kind of change does this PR introduce?

feature

What is the new behavior?

  • syncs project settings
  • syncs branch settings

Additional context

To install development version: go install

  1. create ~/.terraformrc
provider_installation {

  # Use /home/developer/tmp/terraform-null as an overridden package directory
  # for the hashicorp/null provider. This disables the version and checksum
  # verifications for this provider and forces Terraform to look for the
  # null provider plugin in the given directory.
  dev_overrides {
    "supabase/supabase" = "/Users/qiao/go/bin"
  }

  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}
  1. create a main.ts and access-token files
terraform {
  required_providers {
    supabase = {
      source  = "supabase/supabase"
      version = "~> 1.0"
    }
  }
}

provider "supabase" {
  endpoint     = "https://api.supabase.green"
  access_token = file("${path.module}/access-token")
}

# Define a linked project variable as user input
variable "linked_project" {
  type    = string
}

# 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
  })
}

# 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 = jsonencode({
    db_schema            = "public,storage,graphql_public"
    db_extra_search_path = "public,extensions"
    max_rows             = 100
  })
}
  1. Run terraform apply

@sweatybridge sweatybridge changed the title feat: implement basic provider for supabase data source feat: implement basic provider for supabase project settings Jan 23, 2024
@sweatybridge sweatybridge merged commit 8a2ce7f into main Jan 25, 2024
7 checks passed
@sweatybridge sweatybridge deleted the ds-project branch January 25, 2024 03:14
@sweatybridge sweatybridge restored the ds-project branch March 1, 2024 03:13
@sweatybridge sweatybridge deleted the ds-project branch March 1, 2024 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant