Temporal Terraform Orchestrator
Impact Summary
Built a workflow orchestration system using Temporal for managing complex multi-workspace Terraform deployments with automatic dependency resolution, output propagation, and AI integration via MCP.
Role
Creator & Maintainer
Timeline
2025–Present
Scale
- Multi-workspace
- DAG-based orchestration
- AI-integrated
Links
Decision Summary
- • Must handle workspace dependencies automatically (DAG resolution)
- • Output values from one workspace must propagate to dependent workspaces
- • Deployments must survive process restarts (durability requirement)
- • Should support AI-assisted operations for conversational infrastructure management
- + Built-in durability and automatic retries
- + Native support for long-running operations
- + Event sourcing for full auditability
- − Additional infrastructure dependency
- − Learning curve for Temporal patterns
- + Full control over implementation
- + No external dependencies
- − Must build durability from scratch
- − Complex failure handling
- + Familiar tooling
- + Built-in UI
- − Poor support for dynamic dependencies
- − Limited durability guarantees
Problem
Managing Terraform deployments across multiple workspaces with interdependencies is challenging:
- Manual dependency tracking: Teams must manually determine which workspaces depend on others and execute them in the correct order.
- Output propagation: Passing outputs from one workspace as inputs to another requires manual intervention or brittle scripting.
- No parallelization: Without proper orchestration, independent workspaces run sequentially, wasting time.
- Lack of durability: Failed deployments require manual recovery and re-execution.
Approach
I built a Temporal-based orchestration system that treats multi-workspace Terraform deployments as durable workflows with automatic dependency resolution.
Architecture
The system consists of two main workflow types:
- ParentWorkflow: Orchestrates the overall deployment by building a directed acyclic graph (DAG) of workspace dependencies, validating configuration, and managing completion signals.
- TerraformWorkflow: Executes individual workspace operations (init, validate, plan, apply) and captures outputs for downstream consumption.
Key Features
-
Automatic dependency resolution Workspaces declare their dependencies, and the system builds a DAG to determine execution order. Independent workspaces run concurrently for faster deployments.
-
Output propagation Terraform outputs from completed workspaces automatically map to input variables in downstream workspaces through configurable input mappings.
-
Temporal durability Workflows survive worker restarts and failures. Temporal handles automatic retries with exponential backoff, making deployments resilient.
-
MCP server integration AI agents can trigger deployments and monitor execution status through standardized Model Context Protocol tools:
list_workflows: Returns configured workspaces and relationshipsexecute_workflow: Initiates deployment with provided configurationget_workflow_status: Checks execution status by workflow ID
Outcomes
- Faster deployments: Independent workspaces run in parallel, reducing overall deployment time.
- Reliable infrastructure changes: Temporal’s durability guarantees mean deployments complete even through failures.
- AI-assisted operations: MCP integration enables AI agents to manage infrastructure deployments conversationally.
- Clear dependency visualization: The DAG representation makes workspace relationships explicit and auditable.
Key Contributions
- Designed and implemented a Temporal workflow architecture for multi-workspace Terraform orchestration.
- Built automatic dependency resolution using DAG construction with cycle detection.
- Implemented output-to-input mapping for seamless variable propagation between workspaces.
- Created an MCP server enabling AI-driven infrastructure management.
- Documented deployment patterns and configuration schemas for production use.
Related Projects
AWS Security Group Mapper: Visual Analysis Tool for Cloud Security
A Python tool for visualizing AWS security group relationships and generating interactive graphs to help understand complex security architectures.
Fighters Paradise: Modern Game Engine Reimplementation in Rust
A modern Rust reimplementation of the MUGEN 2D fighting game engine with full backward compatibility for existing community content.
Agent-Eval: CI Evaluation Harness for Multi-Agent Development
Behavioral regression testing framework for detecting drift in AI agent instruction files across multi-agent development environments.