|
| 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 | +``` |
0 commit comments