Skip to content

Commit 7af4cac

Browse files
authored
feat: resource for project apikey (#256)
1 parent d6d303f commit 7af4cac

File tree

12 files changed

+799
-9
lines changed

12 files changed

+799
-9
lines changed

docs/data-sources/apikeys.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ data "supabase_apikeys" "production" {
2828
### Read-Only
2929

3030
- `anon_key` (String, Sensitive) Anonymous API key for the project
31+
- `publishable_key` (String, Sensitive) Publishable API key for the project
32+
- `secret_keys` (Attributes List, Sensitive) List of secret API keys for the project (see [below for nested schema](#nestedatt--secret_keys))
3133
- `service_role_key` (String, Sensitive) Service role API key for the project
34+
35+
<a id="nestedatt--secret_keys"></a>
36+
### Nested Schema for `secret_keys`
37+
38+
Read-Only:
39+
40+
- `api_key` (String, Sensitive) The secret API key value
41+
- `name` (String) Name of the secret key

docs/resources/apikey.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "supabase_apikey Resource - terraform-provider-supabase"
4+
subcategory: ""
5+
description: |-
6+
API Key resource
7+
---
8+
9+
# supabase_apikey (Resource)
10+
11+
API Key resource
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "supabase_apikey" "new" {
17+
project_ref = "mayuaycdtijbctgqbycg"
18+
name = "test"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `name` (String) Name of the API key
28+
- `project_ref` (String) Project reference ID
29+
30+
### Optional
31+
32+
- `description` (String) Description of the API key
33+
34+
### Read-Only
35+
36+
- `api_key` (String, Sensitive) API key
37+
- `id` (String) API key identifier
38+
- `secret_jwt_template` (Attributes) Secret JWT template (see [below for nested schema](#nestedatt--secret_jwt_template))
39+
- `type` (String) Type of the API key
40+
41+
<a id="nestedatt--secret_jwt_template"></a>
42+
### Nested Schema for `secret_jwt_template`
43+
44+
Read-Only:
45+
46+
- `role` (String) Role of the secret JWT template
47+
48+
## Import
49+
50+
Import is supported using the following syntax:
51+
52+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
53+
54+
```shell
55+
# The ID is the project reference and a unique identifier of the key separated by '/'
56+
terraform import supabase_apikey.example <project_ref>/<key_id>
57+
```

docs/schema.json

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,68 @@
2424
}
2525
},
2626
"resource_schemas": {
27+
"supabase_apikey": {
28+
"version": 0,
29+
"block": {
30+
"attributes": {
31+
"api_key": {
32+
"type": "string",
33+
"description": "API key",
34+
"description_kind": "markdown",
35+
"computed": true,
36+
"sensitive": true
37+
},
38+
"description": {
39+
"type": "string",
40+
"description": "Description of the API key",
41+
"description_kind": "markdown",
42+
"optional": true
43+
},
44+
"id": {
45+
"type": "string",
46+
"description": "API key identifier",
47+
"description_kind": "markdown",
48+
"computed": true
49+
},
50+
"name": {
51+
"type": "string",
52+
"description": "Name of the API key",
53+
"description_kind": "markdown",
54+
"required": true
55+
},
56+
"project_ref": {
57+
"type": "string",
58+
"description": "Project reference ID",
59+
"description_kind": "markdown",
60+
"required": true
61+
},
62+
"secret_jwt_template": {
63+
"nested_type": {
64+
"attributes": {
65+
"role": {
66+
"type": "string",
67+
"description": "Role of the secret JWT template",
68+
"description_kind": "markdown",
69+
"computed": true
70+
}
71+
},
72+
"nesting_mode": "single"
73+
},
74+
"description": "Secret JWT template",
75+
"description_kind": "markdown",
76+
"computed": true
77+
},
78+
"type": {
79+
"type": "string",
80+
"description": "Type of the API key",
81+
"description_kind": "markdown",
82+
"computed": true
83+
}
84+
},
85+
"description": "API Key resource",
86+
"description_kind": "markdown"
87+
}
88+
},
2789
"supabase_branch": {
2890
"version": 0,
2991
"block": {
@@ -240,6 +302,37 @@
240302
"description_kind": "markdown",
241303
"required": true
242304
},
305+
"publishable_key": {
306+
"type": "string",
307+
"description": "Publishable API key for the project",
308+
"description_kind": "markdown",
309+
"computed": true,
310+
"sensitive": true
311+
},
312+
"secret_keys": {
313+
"nested_type": {
314+
"attributes": {
315+
"api_key": {
316+
"type": "string",
317+
"description": "The secret API key value",
318+
"description_kind": "markdown",
319+
"computed": true,
320+
"sensitive": true
321+
},
322+
"name": {
323+
"type": "string",
324+
"description": "Name of the secret key",
325+
"description_kind": "markdown",
326+
"computed": true
327+
}
328+
},
329+
"nesting_mode": "list"
330+
},
331+
"description": "List of secret API keys for the project",
332+
"description_kind": "markdown",
333+
"computed": true,
334+
"sensitive": true
335+
},
243336
"service_role_key": {
244337
"type": "string",
245338
"description": "Service role API key for the project",

examples/examples.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ var (
99
ProjectResourceConfig string
1010
//go:embed resources/supabase_branch/resource.tf
1111
BranchResourceConfig string
12+
//go:embed resources/supabase_apikey/resource.tf
13+
ApiKeyResourceConfig string
1214
//go:embed data-sources/supabase_branch/data-source.tf
1315
BranchDataSourceConfig string
1416
//go:embed data-sources/supabase_pooler/data-source.tf
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The ID is the project reference and a unique identifier of the key separated by '/'
2+
terraform import supabase_apikey.example <project_ref>/<key_id>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "supabase_apikey" "new" {
2+
project_ref = "mayuaycdtijbctgqbycg"
3+
name = "test"
4+
}

0 commit comments

Comments
 (0)