tharsis_workspace_outputs_json
Retrieves all outputs of a workspace, of any type, as JSON-encoded values.
Example Usage​
terraform {
required_providers {
tharsis = {
source = "registry.terraform.io/martian-cloud/tharsis"
}
}
}
provider "tharsis" {
host = "<tharsis_api_host>"
service_account_id = "<service_account_id>"
service_account_token = "<service_account_token>"
}
data "tharsis_workspace_outputs_json" "this" {
path = "group/sub-group/workspace"
}
# When running via a Tharsis executor, in a workspace,
# the path can be relative to the workspace.
#
# For instance, if you had the following structure where
# you are operating from myworkspace:
# group
# |- sub-group
# |--|- workspace
# |--my-group
# |--|- myworkspace <- this is the current workspace
#
# You can access `workspace` relative to your `myworkspace`
# by using the relative path `../sub-group/workspace`
#
# data "tharsis_workspace_outputs" "this" {
# path = "../sub-group/workspace"
# }
output "object" {
value = jsondecode(data.tharsis_workspace_outputs_json.this.outputs.object)
}
When to use this data source​
Use tharsis_workspace_outputs_json when the workspace has outputs that are lists, maps, objects, or other non-primitive types, or when you want every output regardless of type. Every value is JSON-encoded, so decode it with jsondecode before use.
- A string output includes its surrounding quotes until decoded.
- Bool and number outputs decode to bool and number values.
- Lists, maps, and objects decode to the corresponding Terraform types.
data "tharsis_workspace_outputs_json" "network" {
path = "my-group/network"
}
locals {
subnet_ids = jsondecode(data.tharsis_workspace_outputs_json.network.outputs.subnet_ids)
vpc_name = jsondecode(data.tharsis_workspace_outputs_json.network.outputs.vpc_name)
}
If every output you need is a string, bool, or number, tharsis_workspace_outputs avoids the decoding step.
Selecting the workspace​
Specify the workspace with either path or id, but not both. When running in a Tharsis workspace, path may be relative to the current workspace, for example ../sub-group/workspace. id accepts a workspace ID or TRN.
If the workspace has no state yet, outputs is empty.
Schema​
Optional​
id(String) The ID or TRN of the workspace to retrieve outputs. Either id or path must be specified, but not both.path(String) The path of the workspace to retrieve outputs. Relative paths are supported when running in a Tharsis workspace. Either id or path must be specified, but not both.
Read-Only​
full_path(String) The full path of the workspace.outputs(Map of String) The outputs of the workspace, keyed by output name. Each value is JSON-encoded, so strings include their surrounding quotes. Use jsondecode to convert a value back to its original type.state_version_id(String) The ID of the workspace's current state version.workspace_id(String) The ID of the workspace.