Skip to main content
Glama

apply_run

Execute approved infrastructure changes in Terraform Cloud by confirming and applying a paused run after reviewing the plan output.

Instructions

Apply a run that is paused waiting for confirmation after a plan

Confirms and executes the apply phase for a run that has completed planning and is waiting for approval. Use this when you've reviewed the plan output and want to apply the proposed changes to your infrastructure.

API endpoint: POST /runs/{run_id}/actions/apply

Args: run_id: The ID of the run to apply (format: "run-xxxxxxxx") comment: An optional comment explaining the reason for applying the run

Returns: Run details with updated status information and confirmation of the apply action including timestamp information and any comment provided

See: docs/tools/run.md for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_idYes
commentNo

Implementation Reference

  • The handler function that executes the core logic of the 'apply_run' tool: validates inputs using RunActionRequest, constructs payload with optional comment, and performs POST to /runs/{run_id}/actions/apply via api_request.
    @handle_api_errors async def apply_run(run_id: str, comment: str = "") -> APIResponse: """Apply a run that is paused waiting for confirmation after a plan Confirms and executes the apply phase for a run that has completed planning and is waiting for approval. Use this when you've reviewed the plan output and want to apply the proposed changes to your infrastructure. API endpoint: POST /runs/{run_id}/actions/apply Args: run_id: The ID of the run to apply (format: "run-xxxxxxxx") comment: An optional comment explaining the reason for applying the run Returns: Run details with updated status information and confirmation of the apply action including timestamp information and any comment provided See: docs/tools/run.md for reference documentation """ request = RunActionRequest(run_id=run_id, comment=comment) # Create payload if comment is provided payload = {} if request.comment: payload = {"comment": request.comment} # Make API request return await api_request( f"runs/{run_id}/actions/apply", method="POST", data=payload )
  • Pydantic model RunActionRequest providing input schema validation for apply_run tool parameters: required run_id (run-XXXX) and optional comment.
    class RunActionRequest(APIRequest): """Base request model for run actions like apply, discard, cancel, etc. This model provides common fields used in run action requests such as applying, discarding, or canceling runs. It includes the run ID and an optional comment field that can be included with the action. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#apply-a-run Note: This model is used for multiple run action endpoints that share the same basic structure but perform different operations on the run. See: docs/models/run.md for reference """ run_id: str = Field( ..., # No alias needed as field name matches API field name description="The ID of the run to perform an action on", pattern=r"^run-[a-zA-Z0-9]{16}$", ) comment: Optional[str] = Field( None, # No alias needed as field name matches API field name description="An optional comment about the run", )
  • FastMCP tool registration for 'apply_run' using write_tool_config to enable the tool with appropriate permissions and annotations.
    mcp.tool(**write_tool_config)(runs.apply_run)
  • Import of the runs module containing the apply_run handler, required for registration.
    from terraform_cloud_mcp.tools import runs
  • Configuration dictionary used in registration to control tool enablement and set readOnlyHint annotation to False for write-enabled tools like apply_run.
    write_tool_config = { "enabled": not read_only_mode, "annotations": {"readOnlyHint": False} }

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