assign_variable_set_to_projects
Assign a variable set to multiple projects to make variables available across all workspaces within those projects. Streamlines variable management in Terraform Cloud.
Instructions
Assign a variable set to one or more projects.
Makes the variables in a variable set available to all workspaces within the specified projects.
API endpoint: POST /varsets/{varset_id}/relationships/projects
Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") project_ids: List of project IDs (format: ["prj-xxxxxxxx", ...])
Returns: Empty response with HTTP 204 status code if successful
See: docs/tools/variables.md#assign-variable-set-to-projects for reference documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_ids | Yes | ||
| varset_id | Yes |
Implementation Reference
- The main handler function decorated with @handle_api_errors that implements the tool: assigns a variable set to specified projects by making a POST request to the Terraform Cloud API with the project relationships payload.@handle_api_errors async def assign_variable_set_to_projects( varset_id: str, project_ids: List[str] ) -> APIResponse: """Assign a variable set to one or more projects. Makes the variables in a variable set available to all workspaces within the specified projects. API endpoint: POST /varsets/{varset_id}/relationships/projects Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") project_ids: List of project IDs (format: ["prj-xxxxxxxx", ...]) Returns: Empty response with HTTP 204 status code if successful See: docs/tools/variables.md#assign-variable-set-to-projects for reference documentation """ # Build relationships payload relationships_data = [] for project_id in project_ids: relationships_data.append({"id": project_id, "type": "projects"}) payload = {"data": relationships_data} endpoint = f"varsets/{varset_id}/relationships/projects" return await api_request(endpoint, method="POST", data=payload)
- terraform_cloud_mcp/server.py:138-138 (registration)Registers the 'assign_variable_set_to_projects' tool using the mcp.tool decorator with write_tool_config, likely enabling write permissions.mcp.tool(**write_tool_config)(variables.assign_variable_set_to_projects)