Skip to main content
Glama

update_variable_in_variable_set

Modify specific attributes of an existing variable within a variable set in Terraform Cloud. Update name, value, description, category, HCL status, or sensitivity without altering unspecified attributes.

Instructions

Update an existing variable in a variable set.

Modifies the configuration of an existing variable within a variable set. Only specified attributes will be updated; unspecified attributes remain unchanged.

API endpoint: PATCH /varsets/{varset_id}/relationships/vars/{var_id}

Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") var_id: The ID of the variable (format: "var-xxxxxxxx")

params: Variable parameters to update (optional): - key: New variable name/key - value: New variable value - description: New description of the variable - category: New variable category ("terraform" or "env") - hcl: Whether the value is HCL code (terraform variables only) - sensitive: Whether the variable value is sensitive

Returns: The updated variable with all current settings and configuration

See: docs/tools/variables.md#update-variable-in-variable-set for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNo
var_idYes
varset_idYes

Implementation Reference

  • The handler function that performs the API PATCH request to update a variable in a Terraform Cloud variable set. Uses VariableSetVariableParams for input validation.
    @handle_api_errors async def update_variable_in_variable_set( varset_id: str, var_id: str, params: Optional[VariableSetVariableParams] = None, ) -> APIResponse: """Update an existing variable in a variable set. Modifies the configuration of an existing variable within a variable set. Only specified attributes will be updated; unspecified attributes remain unchanged. API endpoint: PATCH /varsets/{varset_id}/relationships/vars/{var_id} Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") var_id: The ID of the variable (format: "var-xxxxxxxx") params: Variable parameters to update (optional): - key: New variable name/key - value: New variable value - description: New description of the variable - category: New variable category ("terraform" or "env") - hcl: Whether the value is HCL code (terraform variables only) - sensitive: Whether the variable value is sensitive Returns: The updated variable with all current settings and configuration See: docs/tools/variables.md#update-variable-in-variable-set for reference documentation """ param_dict = params.model_dump(exclude_none=True) if params else {} payload = {"data": {"type": "vars", "attributes": param_dict}} return await api_request( f"varsets/{varset_id}/relationships/vars/{var_id}", method="PATCH", data=payload )
  • Tool registration line in the main server.py file, applying write_tool_config which enables the tool unless in read-only mode.
    mcp.tool(**write_tool_config)(variables.update_variable_in_variable_set)
  • Pydantic model defining the input parameters for updating variables in variable sets, used for validation in the handler.
    class VariableSetVariableParams(APIRequest): """Parameters for variable set variable operations without routing fields. This model provides all optional parameters for creating or updating variables within variable sets, separating configuration parameters from routing information like variable set ID and variable ID. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/variable-sets See: docs/models/variables.md for reference """ key: Optional[str] = Field( None, description="Variable name/key", min_length=1, max_length=255, ) value: Optional[str] = Field( None, description="Variable value", max_length=256000, ) description: Optional[str] = Field( None, description="Description of the variable", max_length=512, ) category: Optional[VariableCategory] = Field( None, description="Variable category (terraform or env)", ) hcl: Optional[bool] = Field( None, description="Whether the value is HCL code (only valid for terraform variables)", ) sensitive: Optional[bool] = Field( None, description="Whether the variable value is sensitive", )

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