Blue-green infrastructure pattern
📖 Scenario: You are managing a web application deployment on the cloud. To avoid downtime during updates, you want to use the blue-green deployment pattern. This means you have two identical environments: blue and green. Only one environment serves live traffic at a time. When you update, you deploy to the inactive environment, then switch traffic to it.
🎯 Goal: Create a Terraform configuration that defines two identical infrastructure environments named blue and green. Then add a variable to select which environment is active. Finally, configure a load balancer resource that routes traffic to the active environment only.
📋 What You'll Learn
Define two identical infrastructure resources named
blue and green.Add a variable called
active_environment with allowed values "blue" and "green".Use the
active_environment variable to select which environment the load balancer routes traffic to.The Terraform configuration must be valid and deployable.
💡 Why This Matters
🌍 Real World
Blue-green deployment is a common pattern to update applications without downtime by switching traffic between two identical environments.
💼 Career
Cloud engineers and DevOps professionals use this pattern to ensure smooth, reliable application updates in production.
Progress0 / 4 steps