Skip to main content
Glama

get_errored_state

Retrieve and access state data from a failed Terraform apply for recovery. Use the tool to fetch errored state information via the apply ID, ensuring continued infrastructure management.

Instructions

Retrieve the errored state from a failed apply.

Gets information about a state file that failed to upload during an apply, providing access to the state data for recovery purposes.

API endpoint: GET /applies/{apply_id}/errored-state

Args: apply_id: The ID of the apply with a failed state upload (format: "apply-xxxxxxxx")

Returns: Information about the errored state including access details. The redirect to the state file is automatically followed.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apply_idYes

Implementation Reference

  • The main handler function that implements the logic for retrieving the errored state from a failed Terraform Cloud apply. It validates the input using ApplyErroredStateRequest and calls the API endpoint.
    @handle_api_errors async def get_errored_state(apply_id: str) -> APIResponse: """Retrieve the errored state from a failed apply. Gets information about a state file that failed to upload during an apply, providing access to the state data for recovery purposes. API endpoint: GET /applies/{apply_id}/errored-state Args: apply_id: The ID of the apply with a failed state upload (format: "apply-xxxxxxxx") Returns: Information about the errored state including access details. The redirect to the state file is automatically followed. See: docs/tools/apply.md for reference documentation """ # Validate parameters params = ApplyErroredStateRequest(apply_id=apply_id) # Make API request - redirect handling happens automatically in the API client return await api_request(f"applies/{params.apply_id}/errored-state")
  • Pydantic input schema model used for validating the apply_id parameter in the get_errored_state tool.
    class ApplyErroredStateRequest(APIRequest): """Request model for retrieving an apply's errored state. Used to validate the apply ID parameter for errored state API requests. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/applies#recover-a-failed-state-upload-after-applying See: docs/models/apply.md for reference """ apply_id: str = Field( ..., # No alias needed as field name matches API parameter description="The ID of the apply with a failed state upload", pattern=r"^apply-[a-zA-Z0-9]{16}$", # Standard apply ID pattern )
  • Tool registration in the MCP server using the FastMCP decorator, importing the handler from tools.applies.
    mcp.tool()(applies.get_errored_state)

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