The State File Division Problem
The session opens by addressing a fundamental challenge in Terraform infrastructure management: how to properly divide state files as infrastructure scales. When all environments exist in a single monolithic state file, teams face significant risks including unintended changes to production when modifying development resources, extended execution times as API calls multiply, and unclear ownership boundaries when multiple teams manage different resource types. The speaker illustrates how dividing state files by environment (Prod, Stage, Dev) and resource type (network, compute, database) can transform one state file into twelve separate workspaces, improving isolation and team autonomy but introducing new operational complexity.
Terraform Stacks Architecture and Components
Terraform Stacks introduces a new abstraction layer above workspaces to manage multiple state files as a unified deployment unit. The architecture consists of four core elements: Components define infrastructure resources using standard Terraform code wrapped in new component blocks; Deployments specify target environments including AWS accounts, regions, and IAM roles; Orchestration Rules automate approval workflows and plan execution based on environment-specific policies; and Deferred Changes automatically manage dependencies between components by delaying plans when provider configuration depends on outputs from other components. This structure enables teams to deploy multi-account, multi-region infrastructure configurations while maintaining clear dependency relationships and reducing manual coordination overhead.
Practical Implementation and Current Limitations
The demonstration walks through deploying API Gateway, Lambda, and S3 resources across multiple AWS accounts and regions using Terraform Stacks. The speaker shows how orchestration rules can automate deployments to development and staging environments while requiring manual approval for production, and how deferred changes handle complex scenarios like deploying Kubernetes manifests that depend on EKS cluster endpoints. Currently in public beta and exclusive to HCP Terraform (not available in the community edition), Stacks has a 500-resource limit across all pricing tiers. HashiCorp has indicated some functionality may eventually be integrated into the community version, though timing remains unspecified.