|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "squaredup_dashboard_variable Resource - squaredup" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + Dashboard variables allow you to create flexible and reusable dashboards, allowing dashboard viewers to switch between objects on the fly. |
| 7 | +--- |
| 8 | + |
| 9 | +# squaredup_dashboard_variable (Resource) |
| 10 | + |
| 11 | +Dashboard variables allow you to create flexible and reusable dashboards, allowing dashboard viewers to switch between objects on the fly. |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```terraform |
| 16 | +data "squaredup_datasources" "sample_data" { |
| 17 | + data_source_name = "Sample Data" |
| 18 | +} |
| 19 | +
|
| 20 | +resource "squaredup_datasource" "sample_data_source" { |
| 21 | + display_name = "Sample Data" |
| 22 | + data_source_name = data.squaredup_datasources.sample_data.plugins[0].display_name |
| 23 | +} |
| 24 | +
|
| 25 | +data "squaredup_data_streams" "sample_data_logs_dataStreams" { |
| 26 | + data_source_id = data.squaredup_datasources.sample_data.plugins[0].id |
| 27 | +} |
| 28 | +
|
| 29 | +resource "squaredup_workspace" "application_workspace" { |
| 30 | + display_name = "Application Team" |
| 31 | + description = "Workspace with Dashboards for Application Team" |
| 32 | + datasources_links = [squaredup_datasource.sample_data_source.id] |
| 33 | + tags = ["dashboard-variable"] |
| 34 | +} |
| 35 | +
|
| 36 | +resource "squaredup_scope" "dynamic_scope" { |
| 37 | + scope_type = "dynamic" |
| 38 | + display_name = "Dynamic Scope" |
| 39 | + workspace_id = squaredup_workspace.application_workspace.id |
| 40 | + data_source_id = [squaredup_datasource.sample_data_source.id] |
| 41 | + types = ["sample-function"] |
| 42 | + search_query = "account-common" |
| 43 | +} |
| 44 | +
|
| 45 | +resource "squaredup_dashboard_variable" "example_all_variable" { |
| 46 | + workspace_id = squaredup_workspace.application_workspace.id |
| 47 | + collection_id = squaredup_scope.dynamic_scope.id |
| 48 | + default_object_selection = "all" # or "none" |
| 49 | +} |
| 50 | +
|
| 51 | +resource "squaredup_dashboard" "all_objects" { |
| 52 | + workspace_id = squaredup_workspace.application_workspace.id |
| 53 | + display_name = "All Objects" |
| 54 | + dashboard_variable_id = squaredup_dashboard_variable.example_all_variable.id |
| 55 | + dashboard_template = <<EOT |
| 56 | +{ |
| 57 | + "_type": "layout/grid", |
| 58 | + "contents": [ |
| 59 | + { |
| 60 | + "x": 0, |
| 61 | + "h": 2, |
| 62 | + "i": "ebd9b9cd-2fb3-4978-9a7e-0c96a70a6e41", |
| 63 | + "y": 0, |
| 64 | + "config": { |
| 65 | + "variables": [ |
| 66 | + "{{example_variable_id}}" |
| 67 | + ], |
| 68 | + "scope": { |
| 69 | + "workspace": "{{workspace_id}}", |
| 70 | + "scope": "{{dynamic_scope_id}}" |
| 71 | + }, |
| 72 | + "dataStream": { |
| 73 | + "name": "perf-lambda-duration", |
| 74 | + "id": "{{perf_lambda_duration_datastream_id}}" |
| 75 | + }, |
| 76 | + "_type": "tile/data-stream", |
| 77 | + "description": "", |
| 78 | + "title": "Lambda Duration", |
| 79 | + "visualisation": { |
| 80 | + "type": "data-stream-line-graph", |
| 81 | + "config": { |
| 82 | + "data-stream-line-graph": { |
| 83 | + "seriesColumn": "data.lambdaDuration.label", |
| 84 | + "xAxisColumn": "data.timestamp", |
| 85 | + "yAxisColumn": "data.lambdaDuration.value" |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + }, |
| 90 | + "w": 4 |
| 91 | + } |
| 92 | + ], |
| 93 | + "version": 1, |
| 94 | + "columns": 4 |
| 95 | +} |
| 96 | +EOT |
| 97 | + template_bindings = jsonencode({ |
| 98 | + example_variable_id = squaredup_dashboard_variable.example_variable.id |
| 99 | + workspace_id = squaredup_workspace.application_workspace.id |
| 100 | + dynamic_scope_id = squaredup_scope.dynamic_scope.id |
| 101 | + perf_lambda_duration_datastream_id = data.squaredup_data_streams.sample_data_logs_dataStreams.data_streams[index(data.squaredup_data_streams.sample_data_logs_dataStreams.data_streams.*.definition_name, "perf-lambda-duration")].id |
| 102 | + }) |
| 103 | +} |
| 104 | +
|
| 105 | +resource "squaredup_dashboard_variable" "example_none_variable" { |
| 106 | + workspace_id = squaredup_workspace.application_workspace.id |
| 107 | + collection_id = squaredup_scope.dynamic_scope.id |
| 108 | + default_object_selection = "none" |
| 109 | + allow_multiple_object_selection = true |
| 110 | +} |
| 111 | +
|
| 112 | +resource "squaredup_dashboard" "no_default_objects" { |
| 113 | + workspace_id = squaredup_workspace.application_workspace.id |
| 114 | + display_name = "No Default Objects" |
| 115 | + dashboard_variable_id = squaredup_dashboard_variable.example_none_variable.id |
| 116 | + dashboard_template = <<EOT |
| 117 | +{ |
| 118 | + "_type": "layout/grid", |
| 119 | + "columns": 4, |
| 120 | + "contents": [ |
| 121 | + { |
| 122 | + "i": "5cbfb630-ba91-445a-aaaa-eb7fe9161ca0", |
| 123 | + "x": 0, |
| 124 | + "y": 0, |
| 125 | + "w": 4, |
| 126 | + "h": 2, |
| 127 | + "config": { |
| 128 | + "title": "Cost", |
| 129 | + "description": "", |
| 130 | + "_type": "tile/data-stream", |
| 131 | + "variables": [ |
| 132 | + "{{example_none_variable_id}}" |
| 133 | + ], |
| 134 | + "scope": { |
| 135 | + "scope": "{{dynamic_scope_id}}", |
| 136 | + "workspace": "{{workspace_id}}" |
| 137 | + }, |
| 138 | + "dataStream": { |
| 139 | + "id": "{{perf_cost_datastream_id}}", |
| 140 | + "name": "perf-cost" |
| 141 | + }, |
| 142 | + "visualisation": { |
| 143 | + "type": "data-stream-line-graph", |
| 144 | + "config": { |
| 145 | + "data-stream-line-graph": { |
| 146 | + "xAxisColumn": "data.timestamp", |
| 147 | + "yAxisColumn": "data.cost.value", |
| 148 | + "seriesColumn": "data.cost.label" |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | + ], |
| 155 | + "version": 1 |
| 156 | +} |
| 157 | +EOT |
| 158 | + template_bindings = jsonencode({ |
| 159 | + example_none_variable_id = squaredup_dashboard_variable.example_none_variable.id |
| 160 | + workspace_id = squaredup_workspace.application_workspace.id |
| 161 | + dynamic_scope_id = squaredup_scope.dynamic_scope.id |
| 162 | + perf_cost_datastream_id = data.squaredup_data_streams.sample_data_logs_dataStreams.data_streams[index(data.squaredup_data_streams.sample_data_logs_dataStreams.data_streams.*.definition_name, "perf-cost")].id |
| 163 | + }) |
| 164 | +} |
| 165 | +``` |
| 166 | + |
| 167 | +<!-- schema generated by tfplugindocs --> |
| 168 | +## Schema |
| 169 | + |
| 170 | +### Required |
| 171 | + |
| 172 | +- `collection_id` (String) The id of the collection (scope) for the dashboard variable. |
| 173 | +- `default_object_selection` (String) The default object selection for the dashboard variable. Allowed values: `none`, `all`. |
| 174 | +- `workspace_id` (String) The id of the workspace. |
| 175 | + |
| 176 | +### Optional |
| 177 | + |
| 178 | +- `allow_multiple_object_selection` (Boolean) Whether to allow users to select multiple objects for the dashboard variable. |
| 179 | + |
| 180 | +### Read-Only |
| 181 | + |
| 182 | +- `id` (String) The id of the dashboard variable. |
| 183 | +- `last_updated` (String) Last updated timestamp of the dashboard variable |
| 184 | + |
| 185 | +## Import |
| 186 | + |
| 187 | +Import is supported using the following syntax: |
| 188 | + |
| 189 | +```shell |
| 190 | +# Dashboard variable can be imported using the variable id. |
| 191 | +terraform import squaredup_dashboard_variable.example variable-123 |
| 192 | +``` |
0 commit comments