Skip to content

Commit 58ea898

Browse files
authored
feat: support auth config in settings resource (#16)
* feat: support auth config in settings resource * chore: update readme example and comments
1 parent 810b748 commit 58ea898

File tree

8 files changed

+252
-54
lines changed

8 files changed

+252
-54
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Then commit the changes to `go.mod` and `go.sum`.
4545

4646
## Using the provider
4747

48-
- main.tf
48+
- Example `main.tf`
4949

5050
```hcl
5151
terraform {
@@ -66,6 +66,23 @@ variable "linked_project" {
6666
type = string
6767
}
6868
69+
# Import the linked project resource
70+
import {
71+
to = supabase_project.production
72+
id = var.linked_project
73+
}
74+
75+
resource "supabase_project" "production" {
76+
organization_id = "nknnyrtlhxudbsbuazsu"
77+
name = "tf-project"
78+
database_password = "tf-example"
79+
region = "ap-southeast-1"
80+
81+
lifecycle {
82+
ignore_changes = [database_password]
83+
}
84+
}
85+
6986
# Configure api settings for the linked project
7087
resource "supabase_settings" "production" {
7188
project_ref = var.linked_project
@@ -88,10 +105,10 @@ resource "supabase_settings" "branch" {
88105
89106
project_ref = each.key
90107
91-
api = jsonencode({
92-
db_schema = "public,storage,graphql_public"
93-
db_extra_search_path = "public,extensions"
94-
max_rows = 100
108+
api = supabase_settings.production.api
109+
110+
auth = jsonencode({
111+
site_url = "http://localhost:3000"
95112
})
96113
}
97114
```

docs/resources/settings.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ resource "supabase_settings" "production" {
2121
db_extra_search_path = "public,extensions"
2222
max_rows = 1000
2323
})
24+
25+
auth = jsonencode({
26+
site_url = "http://localhost:3000"
27+
})
2428
}
2529
```
2630

examples/resources/supabase_settings/resource.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ resource "supabase_settings" "production" {
66
db_extra_search_path = "public,extensions"
77
max_rows = 1000
88
})
9+
10+
auth = jsonencode({
11+
site_url = "http://localhost:3000"
12+
})
913
}

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/terraform-plugin-go v0.21.0
1313
github.com/hashicorp/terraform-plugin-log v0.9.0
1414
github.com/hashicorp/terraform-plugin-testing v1.6.0
15-
github.com/supabase/cli v1.137.0
15+
github.com/supabase/cli v1.144.0
1616
gopkg.in/h2non/gock.v1 v1.1.2
1717
)
1818

@@ -31,7 +31,7 @@ require (
3131
github.com/fatih/color v1.16.0 // indirect
3232
github.com/golang/protobuf v1.5.3 // indirect
3333
github.com/google/go-cmp v0.6.0 // indirect
34-
github.com/google/uuid v1.5.0 // indirect
34+
github.com/google/uuid v1.6.0 // indirect
3535
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
3636
github.com/hashicorp/cli v1.1.6 // indirect
3737
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -65,7 +65,7 @@ require (
6565
github.com/oapi-codegen/runtime v1.1.1 // indirect
6666
github.com/oklog/run v1.0.0 // indirect
6767
github.com/posener/complete v1.2.3 // indirect
68-
github.com/rivo/uniseg v0.4.4 // indirect
68+
github.com/rivo/uniseg v0.4.6 // indirect
6969
github.com/russross/blackfriday v1.6.0 // indirect
7070
github.com/shopspring/decimal v1.3.1 // indirect
7171
github.com/spf13/cast v1.6.0 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
5252
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
5353
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5454
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
55-
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
56-
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
55+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
56+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5757
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
5858
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
5959
github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8=
@@ -159,8 +159,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
159159
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
160160
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
161161
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
162-
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
163-
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
162+
github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
163+
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
164164
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
165165
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
166166
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
@@ -180,8 +180,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
180180
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
181181
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
182182
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
183-
github.com/supabase/cli v1.137.0 h1:1zw+HA2cUVoVkBtRY1QS2tiIvDN9gklL4sBHtqcaDmw=
184-
github.com/supabase/cli v1.137.0/go.mod h1:qGKDc+lh410trY+P2KsW9rMQLmdyzni1ON5Zx2HoBAs=
183+
github.com/supabase/cli v1.144.0 h1:8W9E3syQMcGOyDjvZ95Y6XE2kAgxfKM3fh62ftotL7o=
184+
github.com/supabase/cli v1.144.0/go.mod h1:Q9hI7y4DbHYevgxLsVIDMswKtP3vWB25vg188TV+aCk=
185185
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
186186
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
187187
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=

internal/provider/project_resource.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ func createProject(ctx context.Context, data *ProjectResourceModel, client *api.
189189
Name: data.Name.ValueString(),
190190
DbPass: data.DatabasePassword.ValueString(),
191191
Region: api.CreateProjectBodyRegion(data.Region.ValueString()),
192-
// TODO: the plan field is deprecated, remove after API fix is deployed
193-
Plan: api.CreateProjectBodyPlanFree,
194192
})
195193

196194
if err != nil {

0 commit comments

Comments
 (0)