In the Using workspaces for managing environments recipe in Chapter 4, Using the Terraform CLI, we studied the use of some Terraform commands to manage and create workspaces. In Terraform's vision, workspaces make it possible to manage several environments by creating several Terraform state files for the same Terraform configuration.
In this recipe, we will go further with the use of workspaces by automating their creation in a CI/CD pipeline.
Getting ready
The prerequisite for this recipe is to know the Terraform command-line options for the workspaces, the documentation for which is available at https://www.terraform.io/docs/commands/workspace/index.html.
Concerning the CI/CD pipeline, we will implement it in Azure Pipelines, which we have already seen in this chapter, in the Building CI/CD pipelines for Terraform configuration in Azure Pipelines recipe.
The purpose of this recipe is to illustrate a scenario I recently implemented, which is the...