I’m implementing a GitOps workflow with GitHub Actions and Terraform Cloud to manage AWS infrastructure across multiple regions for both staging and production environments.
My current requirements:
- Push to staging branch should trigger
terraform apply
for staging infrastructure across multiple regions - Push to production branch should trigger
terraform apply
for production infrastructure across multiple regions - Need to maintain separate state files or workspaces(?) for proper isolation
Key questions:
- What’s the correct way to dynamically select/switch Terraform Cloud workspaces within a GitHub Actions pipeline? The docs only distinguish here without clearly guiding.
- Should I handle multiple regions through GitHub Actions matrix strategy or within Terraform code itself?
- If using a matrix strategy, how do I properly configure workspace selection for each region/environment combination?
- What’s the recommended workspace structure in Terraform Cloud for this scenario?