Skip to content

Commit 3e517a6

Browse files
authored
[feat][gov] Add ability to manage resources (#55)
* update repo to reflect v.2.9.0 of the api * fixes to cursor slop * notes in readme * all tests passing, working on a local server with real examples * docs * lint fixes * add comment on folder deletion recursion * notes on reviewing * better handling for config variables as secret * update docs * lint * lint * add resources resource * docs * fix test * lint * lint * lint * docs update * more accurate docs
1 parent 46d0dcc commit 3e517a6

File tree

9 files changed

+891
-0
lines changed

9 files changed

+891
-0
lines changed

docs/resources/resource.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
page_title: "Resource: retool_resource"
3+
description: |-
4+
A Retool resource represents a connection to an external service such as a database, API, or other data source.
5+
Important Note: Due to API security design, the options field (which contains connection credentials and configuration) is write-only and cannot be read back after creation. This means:
6+
Changes to options will not be detected by Terraform after the resource is createdThe options value will not be stored in Terraform state after initial creationTo update resource options, you must use the Retool UI or recreate the resource
7+
---
8+
9+
# Resource: retool_resource
10+
11+
A Retool resource represents a connection to an external service such as a database, API, or other data source.
12+
13+
**Important Note:** Due to API security design, the options field (which contains connection credentials and configuration) is write-only and cannot be read back after creation. This means:
14+
- Changes to options will not be detected by Terraform after the resource is created
15+
- The options value will not be stored in Terraform state after initial creation
16+
- To update resource options, you must use the Retool UI or recreate the resource
17+
18+
## Example Usage
19+
20+
```terraform
21+
resource "retool_resource" "api" {
22+
display_name = "My REST API"
23+
type = "restapi"
24+
25+
options = jsonencode({
26+
base_url = "https://api.example.com"
27+
})
28+
29+
lifecycle {
30+
# Ignore changes to options since they can't be read back from the API
31+
ignore_changes = [options]
32+
}
33+
}
34+
35+
resource "retool_resource" "api" {
36+
display_name = "My REST API"
37+
type = "restapi"
38+
39+
options = jsonencode({
40+
base_url = "https://api.example.com"
41+
authentication_options = {
42+
authentication_type = "basic"
43+
basic_username = "admin"
44+
basic_password = "password"
45+
}
46+
})
47+
48+
lifecycle {
49+
# Ignore changes to options since they can't be read back from the API
50+
ignore_changes = [options]
51+
}
52+
}
53+
54+
resource "retool_resource" "database" {
55+
display_name = "Production Database"
56+
type = "postgresql"
57+
58+
options = jsonencode({
59+
host = "db.example.com"
60+
port = 5432
61+
database_name = "myapp"
62+
database_username = var.db_username
63+
database_password = var.db_password
64+
ssl_settings = {
65+
ssl_enabled = true
66+
}
67+
})
68+
69+
lifecycle {
70+
ignore_changes = [options]
71+
}
72+
}
73+
```
74+
75+
<!-- schema generated by tfplugindocs -->
76+
## Schema
77+
78+
### Required
79+
80+
- `display_name` (String) The display name of the resource.
81+
- `options` (String, Sensitive) JSON string containing the resource configuration options. The structure varies by resource type. This field is write-only and cannot be read back after creation.
82+
- `type` (String) The type of resource (e.g., 'restapi', 'postgresql', 'mysql', 'snowflake'). Cannot be changed after creation.
83+
84+
### Read-Only
85+
86+
- `created_at` (String) The timestamp when the resource was created.
87+
- `id` (String) The UUID of the resource.
88+
- `protected` (Boolean) Whether the resource is protected in source control.
89+
- `updated_at` (String) The timestamp when the resource was last updated.
90+
91+
## Import
92+
93+
Import is supported using the following syntax:
94+
95+
```shell
96+
#!/bin/bash
97+
# Import a Retool resource using its UUID
98+
# Note: The options field will not be imported and must be set in your configuration
99+
terraform import retool_resource.example "resource_uuid_here"
100+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# Import a Retool resource using its UUID
3+
# Note: The options field will not be imported and must be set in your configuration
4+
terraform import retool_resource.example "resource_uuid_here"
5+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
resource "retool_resource" "api" {
2+
display_name = "My REST API"
3+
type = "restapi"
4+
5+
options = jsonencode({
6+
base_url = "https://api.example.com"
7+
})
8+
9+
lifecycle {
10+
# Ignore changes to options since they can't be read back from the API
11+
ignore_changes = [options]
12+
}
13+
}
14+
15+
resource "retool_resource" "api" {
16+
display_name = "My REST API"
17+
type = "restapi"
18+
19+
options = jsonencode({
20+
base_url = "https://api.example.com"
21+
authentication_options = {
22+
authentication_type = "basic"
23+
basic_username = "admin"
24+
basic_password = "password"
25+
}
26+
})
27+
28+
lifecycle {
29+
# Ignore changes to options since they can't be read back from the API
30+
ignore_changes = [options]
31+
}
32+
}
33+
34+
resource "retool_resource" "database" {
35+
display_name = "Production Database"
36+
type = "postgresql"
37+
38+
options = jsonencode({
39+
host = "db.example.com"
40+
port = 5432
41+
database_name = "myapp"
42+
database_username = var.db_username
43+
database_password = var.db_password
44+
ssl_settings = {
45+
ssl_enabled = true
46+
}
47+
})
48+
49+
lifecycle {
50+
ignore_changes = [options]
51+
}
52+
}
53+

internal/provider/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/tryretool/terraform-provider-retool/internal/provider/folder"
2525
"github.com/tryretool/terraform-provider-retool/internal/provider/group"
2626
"github.com/tryretool/terraform-provider-retool/internal/provider/permissions"
27+
"github.com/tryretool/terraform-provider-retool/internal/provider/retoolresource"
2728
"github.com/tryretool/terraform-provider-retool/internal/provider/sourcecontrol"
2829
"github.com/tryretool/terraform-provider-retool/internal/provider/sourcecontrolsettings"
2930
"github.com/tryretool/terraform-provider-retool/internal/provider/space"
@@ -301,6 +302,7 @@ func (p *retoolProvider) Resources(_ context.Context) []func() resource.Resource
301302
folder.NewResource,
302303
group.NewResource,
303304
permissions.NewResource,
305+
retoolresource.NewResource,
304306
space.NewResource,
305307
sso.NewResource,
306308
sourcecontrol.NewResource,

0 commit comments

Comments
 (0)