Creating and switching workspaces
📖 Scenario: You are managing infrastructure using Terraform. You want to organize your infrastructure configurations by using different workspaces. Each workspace allows you to have separate states for different environments like development and production.
🎯 Goal: Create a Terraform configuration that initializes a workspace called dev, switches to it, and then creates another workspace called prod and switches to it.
📋 What You'll Learn
Create a Terraform configuration file named
main.tf with a basic provider setup.Initialize Terraform in the current directory.
Create a workspace named
dev using Terraform CLI commands.Switch to the
dev workspace.Create a workspace named
prod using Terraform CLI commands.Switch to the
prod workspace.💡 Why This Matters
🌍 Real World
Terraform workspaces are used to manage different environments such as development, testing, and production within the same configuration codebase.
💼 Career
Knowing how to create and switch Terraform workspaces is essential for infrastructure engineers and DevOps professionals to manage infrastructure lifecycle safely and efficiently.
Progress0 / 4 steps