This is about Terraform CLI Workspaces - not Terraform Cloud Workspaces. Those are different things for historic reasons. Hashicorp article

Let’s create our first pull request with a change and see this in action

  1. Fork the demo repository

  2. Enable Actions (by default workflows won’t trigger in a fork)

  1. In your repository settings > Actions ensure that the Workflow Read and Write permissions are assigned - This will allow the workflow to post comments on your PRs

  1. Add environment variables into your Github Action Secrets (cloud keys are a requirement since digger needs to connect to your account for coordinating locks). In this case we are setting AWS keys for this demo but you can follow GCP or Azure steps as seen fit.

  1. make a change in main.tf and create a PR -you can just rename an existing null resource to test it. Notice that we have digger.yml where we have two workspaces defined: one for dev and the other for prod. Therefore Digger will create two plans for us:

  1. Lets apply the PR and merge it to unlock the flow for our colleagues. We can do this by commenting digger apply

Conclusion

In this tutorial we created a workspace enabled example with terraform and workspaces to provision two environments with independent states.