Skip to main content

tharsis_workspace_outputs

Retrieves the string, bool, and number outputs of a workspace. Use tharsis_workspace_outputs_json for other types.

Example Usage​

terraform {
required_providers {
tharsis = {
source = "registry.terraform.io/martian-cloud/tharsis"
}
}
}

provider "tharsis" {
host = "<tharsis_api_host>"
static_token = "<static_token>"
}

data "tharsis_workspace_outputs" "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 "str" {
value = data.tharsis_workspace_outputs.this.outputs.output_name
}

When to use this data source​

Use tharsis_workspace_outputs when the outputs you need are strings, bools, or numbers. Each value is available directly as outputs.<name>.

  • String outputs are returned as-is.
  • Bool and number outputs are returned in string form, for example "true" or "42". Use tobool or tonumber when the consuming argument requires that type.
  • Outputs of any other type (lists, sets, maps, tuples, and objects) are skipped, and a warning is reported for each one. To read those, use tharsis_workspace_outputs_json.
data "tharsis_workspace_outputs" "network" {
path = "my-group/network"
}

# A string output is used as-is.
# A number output is converted from its string form.
resource "example_thing" "this" {
subnet_id = data.tharsis_workspace_outputs.network.outputs.subnet_id
size = tonumber(data.tharsis_workspace_outputs.network.outputs.size)
}

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. String values are returned as-is, and bool and number values are returned as their string form (for example "true" or "42").
  • state_version_id (String) The ID of the workspace's current state version.
  • workspace_id (String) The ID of the workspace.