Working with workspaces in CI/CD
In the Using workspaces for managing environments recipe in Chapter 6, Applying a Basic Terraform Workflow, we studied the use of some Terraform commands to manage and create workspaces. In Terraform CLI workspaces, 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 CLI 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 to apply Terraform configurations in Azure Pipelines recipe.
The purpose of this recipe is to illustrate a scenario I...