0
0
Terraformcloud~30 mins

Workspaces and remote state in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Manage Terraform Workspaces and Remote State
📖 Scenario: You are managing infrastructure for a small company. You want to keep your Terraform state files safe and organized by using workspaces and storing the state remotely in an S3 bucket.
🎯 Goal: Create a Terraform configuration that initializes an S3 backend for remote state storage and uses workspaces to separate environments.
📋 What You'll Learn
Create a Terraform backend configuration for an S3 bucket named my-terraform-state-bucket in the us-east-1 region.
Configure the backend to use the key terraform.tfstate.
Create a workspace named dev.
Create a workspace named prod.
💡 Why This Matters
🌍 Real World
Using remote state storage and workspaces helps teams safely manage infrastructure changes for multiple environments without conflicts.
💼 Career
Cloud engineers and DevOps professionals use Terraform backends and workspaces daily to organize infrastructure code and collaborate effectively.
Progress0 / 4 steps
1
Create Terraform backend configuration for S3
Write a Terraform terraform block that configures the backend to use an S3 bucket named my-terraform-state-bucket in the us-east-1 region with the key terraform.tfstate.
Terraform
Need a hint?

Use the terraform block with a backend "s3" configuration inside.

2
Initialize Terraform with backend
Add a comment line # Run terraform init to initialize the backend to remind yourself to initialize Terraform after backend configuration.
Terraform
Need a hint?

Just add a comment reminding to run terraform init.

3
Create Terraform workspace dev
Add a comment line # Run terraform workspace new dev to remind yourself to create the dev workspace.
Terraform
Need a hint?

Add a comment to remind creating the dev workspace with terraform workspace new dev.

4
Create Terraform workspace prod
Add a comment line # Run terraform workspace new prod to remind yourself to create the prod workspace.
Terraform
Need a hint?

Add a comment to remind creating the prod workspace with terraform workspace new prod.