Skip to main content
Glama

assign_variable_set_to_workspaces

Assign variable sets to specific workspaces in Terraform Cloud, ensuring variables are available and take precedence when priority is enabled. Use the API to link variable sets to workspaces for efficient infrastructure management.

Instructions

Assign a variable set to one or more workspaces.

Makes the variables in a variable set available to the specified workspaces. Variables from variable sets take precedence over workspace variables if the variable set has priority enabled.

API endpoint: POST /varsets/{varset_id}/relationships/workspaces

Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") workspace_ids: List of workspace IDs (format: ["ws-xxxxxxxx", ...])

Returns: Empty response with HTTP 204 status code if successful

See: docs/tools/variables.md#assign-variable-set-to-workspaces for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
varset_idYes
workspace_idsYes

Implementation Reference

  • The core handler function decorated with error handling that implements the tool by building a JSON-API relationships payload for workspaces and POSTing it to the Terraform Cloud API to assign the variable set.
    @handle_api_errors async def assign_variable_set_to_workspaces( varset_id: str, workspace_ids: List[str] ) -> APIResponse: """Assign a variable set to one or more workspaces. Makes the variables in a variable set available to the specified workspaces. Variables from variable sets take precedence over workspace variables if the variable set has priority enabled. API endpoint: POST /varsets/{varset_id}/relationships/workspaces Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") workspace_ids: List of workspace IDs (format: ["ws-xxxxxxxx", ...]) Returns: Empty response with HTTP 204 status code if successful See: docs/tools/variables.md#assign-variable-set-to-workspaces for reference documentation """ # Build relationships payload relationships_data = [] for workspace_id in workspace_ids: relationships_data.append({"id": workspace_id, "type": "workspaces"}) payload = {"data": relationships_data} endpoint = f"varsets/{varset_id}/relationships/workspaces" return await api_request(endpoint, method="POST", data=payload)
  • Registers the tool function imported from the variables module using FastMCP's mcp.tool decorator with write_tool_config enabling it for non-read-only mode.
    mcp.tool(**write_tool_config)(variables.assign_variable_set_to_workspaces)

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/severity1/terraform-cloud-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server