update_variable_set
Modify Terraform Cloud variable set configurations like name, description, global scope, or priority settings to adapt infrastructure management parameters.
Instructions
Update an existing variable set.
Modifies the settings of a variable set. Only specified attributes will be updated; unspecified attributes remain unchanged.
API endpoint: PATCH /varsets/{varset_id}
Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx")
Returns: The updated variable set with all current settings and configuration
See: docs/tools/variables.md#update-variable-set for reference documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| varset_id | Yes | ||
| params | No |
Implementation Reference
- The async handler function implementing the core logic for the 'update_variable_set' tool. It validates input using VariableSetParams, constructs the API payload, and performs a PATCH request to update the variable set in Terraform Cloud.@handle_api_errors async def update_variable_set( varset_id: str, params: Optional[VariableSetParams] = None, ) -> APIResponse: """Update an existing variable set. Modifies the settings of a variable set. Only specified attributes will be updated; unspecified attributes remain unchanged. API endpoint: PATCH /varsets/{varset_id} Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") params: Variable set parameters to update (optional): - name: New name for the variable set - description: New description of the variable set - global: Whether this is a global variable set - priority: Whether this variable set takes priority over workspace variables Returns: The updated variable set with all current settings and configuration See: docs/tools/variables.md#update-variable-set for reference documentation """ param_dict = params.model_dump(exclude_none=True) if params else {} request = VariableSetUpdateRequest(varset_id=varset_id, **param_dict) payload = create_api_payload( resource_type="varsets", model=request, exclude_fields={"varset_id"} ) return await api_request(f"varsets/{varset_id}", method="PATCH", data=payload)
- Pydantic schema model 'VariableSetParams' used for input validation of optional parameters (name, description, global, priority) passed to the update_variable_set handler.class VariableSetParams(APIRequest): """Parameters for variable set operations without routing fields. This model provides all optional parameters for creating or updating variable sets, separating configuration parameters from routing information. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/variable-sets See: docs/models/variables.md for reference """ name: Optional[str] = Field( None, description="Variable set name", min_length=1, max_length=90, ) description: Optional[str] = Field( None, description="Description of the variable set", max_length=512, ) global_: Optional[bool] = Field( None, alias="global", description="Whether this is a global variable set", ) priority: Optional[bool] = Field( None, description="Whether this variable set takes priority over workspace variables", )
- terraform_cloud_mcp/server.py:134-134 (registration)Tool registration line where 'update_variable_set' is registered as an MCP tool with write permissions configuration (enabled only if not in read-only mode).mcp.tool(**write_tool_config)(variables.update_variable_set)
- Internal Pydantic request model 'VariableSetUpdateRequest' constructed in the handler, including varset_id validation and embedding VariableSetParams.class VariableSetUpdateRequest(APIRequest): """Request model for updating variable sets. Used for PATCH /varsets/:varset_id endpoint. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/variable-sets See: docs/models/variables.md for reference """ varset_id: str = Field( ..., description="The variable set ID", pattern=r"^varset-[a-zA-Z0-9]{16}$", ) params: Optional[VariableSetParams] = Field( None, description="Variable set parameters to update", )