Creating A Terraform Workspace If It Doesn't Exist

Today, I needed to add a step to my GitHub Actions workflow to create a Terraform workspace if it doesn’t exist.

You can do that like this:

terraform init
terraform workspace select -or-create <workspace name>


Join the 80/20 DevOps Newsletter

If you're an engineering leader or developer, you should subscribe to my 80/20 DevOps Newsletter. Give me 1 minute of your day, and I'll teach you essential DevOps skills. I cover topics like Kubernetes, AWS, Infrastructure as Code, and more.

Not sure yet? Check out the archive.

Unsubscribe at any time.