Managing multiple regions and environments (staging/prod) with Terraform Cloud in GitHub Actions

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:

  1. 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.
  2. Should I handle multiple regions through GitHub Actions matrix strategy or within Terraform code itself?
  3. If using a matrix strategy, how do I properly configure workspace selection for each region/environment combination?
  4. What’s the recommended workspace structure in Terraform Cloud for this scenario?