# Blue-Green Deployment

Blue-green deployment releases a new application version into a separate environment and then redirects production traffic from the current environment to the new one.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/blue-green-deployment

> Two independently deployable environments allow engineers to validate a replacement release while the existing release continues serving users. Switching traffic rather than modifying the live environment reduces deployment disruption and can enable fast rollback, provided data and dependencies remain compatible.

Practice exams covering Blue-Green Deployment: [ANS-C01 AWS Certified Advanced Networking - Specialty](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty), [AIB-C01 (beta) AWS Certified AI Business Strategist](https://blowstack.com/practice-exams/aws-certified-ai-business-strategist), [SOA-C03 AWS Certified CloudOps Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SAA-C03 AWS Certified Solutions Architect - Associate](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Blue-Green Deployment

Blue-green deployment combines isolated release preparation, controlled routing, production validation, and state-aware rollback at the cost of temporary duplicate capacity.

1. **Separate current and replacement environments**: Keep the active release available while preparing the replacement independently. Match relevant configuration, networking, permissions, and dependencies so validation reflects production behavior.
2. **Controlled traffic cutover**: Promote a release by changing routing rather than upgrading the live application in place. Plan connection draining, session handling, and propagation delays around the chosen routing mechanism.
3. **Reproducible, immutable releases**: Build environments from versioned artifacts and infrastructure definitions. Replacing application instances reduces configuration drift, but mutable shared dependencies still require explicit management.
4. **Validated and observable promotion**: Run readiness checks and representative application tests before cutover, then monitor technical and business indicators afterward. For AI workloads, include model quality, data compatibility, inference performance, and operational fallback criteria.
5. **Rollback with state compatibility**: Retain the previous environment for a defined rollback window and automate traffic restoration when appropriate. Ensure old code can still interpret current data because reversing routing does not reverse database changes or external side effects.
6. **Temporary capacity and cost overhead**: Budget for overlapping environments, including compute, model hosting, and supporting resources. Check service quotas and replacement capacity before deployment, then remove unused resources after the observation period.

## Cloud services for Blue-Green Deployment

A deployment workflow prepares a replacement application or model environment, validates it, and changes the production routing target. CodeDeploy can coordinate supported deployments across EC2, ECS, and Lambda, while Elastic Load Balancing routes application traffic between fleets. Lambda aliases provide version-level routing for serverless releases. SageMaker AI deployment guardrails provide a comparable managed workflow for supported inference endpoint updates. CloudWatch supplies metrics and alarms for observation and rollback decisions. These services implement different parts of the pattern; they do not remove the need to design compatible database changes, representative tests, sufficient temporary capacity, and a clear rollback window.

- **[AWS CodeDeploy](https://blowstack.com/tools/cloud-services-hub/aws-codedeploy)**: Automates blue-green deployments for supported Amazon EC2, Amazon ECS, and AWS Lambda deployment scenarios. Traffic-shifting options differ by compute platform; deployment hooks and configured CloudWatch alarms can support validation and automatic rollback.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Published function versions provide immutable deployment artifacts, and an alias can direct invocations to the selected version. CodeDeploy can manage version traffic shifts and rollback; callers must use the deployment alias rather than bypassing it with direct version references.
- **[Amazon SageMaker](https://blowstack.com/tools/cloud-services-hub/amazon-sagemaker)**: Deployment guardrails support blue-green updates for supported real-time inference endpoints using a replacement fleet. Traffic-shifting policies, a baking period, and configured CloudWatch alarms help validate a new deployment and trigger rollback when alarms indicate problems.
- **[Amazon CloudWatch](https://blowstack.com/tools/cloud-services-hub/amazon-cloudwatch)**: Collects deployment health metrics, logs, and application signals used to evaluate the replacement environment. Alarms can participate in supported automated rollback workflows, but useful thresholds and business-level metrics must be explicitly configured.

## Blue-Green Deployment exam questions

Real practice exam questions on Blue-Green Deployment, with the correct answer and its explanation.

### Question 1 (AIB-C01 (beta))

**Question:**

An insurance company uses an external generative AI platform to draft claim summaries for employee review. It is considering moving the application to Amazon Bedrock to reduce total annual costs by at least 20%. The company must preserve summary quality, meet its existing peak-period response-time target, and avoid interrupting claims processing. Published model prices suggest lower inference costs, but the current application uses provider-specific prompts and response formats. Which transition strategy BEST aligns with the company's objectives?

**Correct answer:** Validate the Bedrock application in a separate environment using representative claims and peak workloads. Compare quality, response times, and annual costs including migration, integration, employee review, and temporary parallel operation. Switch traffic only when targets are met, retaining a compatible rollback path.

**Explanation:** This strategy validates the business case against the actual workload rather than model prices alone. It accounts for total cost of ownership and verifies quality and performance. Separately deployable environments with a compatible rollback path support business continuity during the transition.

### Question 2 (MLA-C02 (beta))

**Question:**

A company hosts a fraud-detection model in an Amazon ECS service on AWS Fargate behind an Application Load Balancer. Each release includes a new model and inference container. The company wants a managed deployment process that creates a replacement task set and tests it through a separate test listener while the existing task set continues serving all production requests. Automated tests must submit known transactions and verify the candidate model's predictions. If any prediction fails validation, the deployment must fail without routing production traffic to the candidate. Both model versions can pass the load balancer's HTTP health checks. Which solution meets these requirements?

**Correct answer:** Use an AWS CodeDeploy ECS blue/green deployment with an AfterAllowTestTraffic Lambda hook. Have the hook validate predictions through the test listener and report Succeeded or Failed by calling PutLifecycleEventHookExecutionStatus. Enable automatic rollback on deployment failure.

**Explanation:** AfterAllowTestTraffic runs after the test listener routes requests to the replacement task set and before production traffic shifts. The Lambda hook can validate the candidate model and explicitly report failure to CodeDeploy. A failed validation prevents production traffic shifting, and automatic rollback handles the failed deployment.

### Question 3 (SAP-C03)

**Question:**

A company runs a customer portal on an Amazon EC2 Auto Scaling group behind an Application Load Balancer (ALB). Each instance requires 15 minutes to load reference data before it can serve requests. Session state is stored externally, and both application versions can safely use the same production database.

The release pipeline must validate each candidate at production capacity without sending customer requests to it. After approval, all new customer requests must be directed to the candidate. If an application-level Amazon CloudWatch alarm enters ALARM during the next 60 minutes, automation must restore routing to the previous release within 90 seconds, without launching instances or reinstalling application artifacts. Some customers use DNS resolvers that cache responses for at least 5 minutes.

Which deployment design meets these requirements?

**Correct answer:** Create a second full-capacity Auto Scaling group with a separate ALB target group. Validate the candidate through a restricted test listener, and then change the production listener to forward to its target group. Keep the previous group running and registered in its original target group for 60 minutes. Configure alarm-triggered automation to restore the production listener's previous forwarding action.

**Explanation:** The replacement environment can be validated independently before receiving customer traffic. Switching the production listener changes routing without depending on DNS cache expiration. Retaining the previous environment at full capacity allows automation to restore routing without instance startup or artifact installation. External session state and database compatibility make the previous release usable after promotion.

### Question 4 (SOA-C03)

**Question:**

A company runs a latency-sensitive API on AWS Lambda. All production requests invoke a production alias that points to published version 21. Provisioned concurrency is configured directly on version 21.

A CloudOps engineer has published and functionally tested version 22. Before switching production traffic, the engineer must preinitialize 40 execution environments for version 22 while preserving version 21's existing provisioned capacity. Clients must continue using the same alias ARN. Sufficient concurrency quotas are available, and the production alias has no provisioned concurrency configuration of its own.

Which deployment procedure meets these requirements?

**Correct answer:** Configure provisioned concurrency of 40 directly on version 22, wait until its provisioned concurrency status is READY, and update the production alias to point to version 22.

**Explanation:** Provisioned concurrency initializes execution environments for the specified published version. Waiting for READY ensures that allocation has completed before production traffic switches. Updating the existing alias preserves the client invocation ARN, and the separate allocation on version 21 remains unchanged.

### Question 5 (DOP-C02)

**Question:**

A company uses AWS CodeDeploy to deploy an Amazon ECS service on AWS Fargate behind an Application Load Balancer. The deployment group has two target groups, CloudWatch alarm monitoring, and automatic rollback configured. Deployments currently shift all production traffic to the replacement task set at once.

A new release policy requires a healthy replacement task set to receive approximately 20% of production traffic initially. Traffic must then increase by 20 percentage points every 4 minutes until the replacement receives all production traffic. The original task set must remain available for 10 minutes after deployment completion. The team must use CodeDeploy-managed traffic shifting without pipeline scripts that modify listener weights.

Which configuration meets these requirements?

**Correct answer:** Create a custom ECS deployment configuration with TimeBasedLinear, LinearPercentage set to 20, and LinearInterval set to 4. Associate it with the deployment group and set terminationWaitTimeInMinutes to 10 with termination of the original task set enabled.

**Explanation:** An ECS TimeBasedLinear deployment configuration increases replacement traffic by the specified percentage at each interval. These values provide an initial 20% share followed by 20-percentage-point increases every 4 minutes. The separate termination wait retains the original task set for 10 minutes after deployment completion. The existing alarm and rollback configuration continues to protect the deployment.

### Question 6 (ANS-C01)

**Question:**

A company runs an internal HTTPS API on an EC2 Auto Scaling group across three Availability Zones. An internal Application Load Balancer (ALB) accepts production traffic on port 443 and forwards it to the current release. A replacement release requires a separately scalable fleet that can handle the entire production workload. Both releases use a shared database with backward-compatible schema changes.

Before approval, deployment runners in the same VPC must validate the replacement through the existing ALB, but production clients must not be able to access it. After approval, the company must redirect new production requests to the replacement without changing DNS or registering or deregistering targets during cutover. The previous fleet must remain available for rollback without redeployment. Existing requests may finish on the previous fleet. Production clients require only port 443.

Which design meets these requirements?

**Correct answer:** Create a separate Auto Scaling group and target group for the replacement. Add an HTTPS listener on port 8443 that forwards to the replacement target group, and permit access to that port only from the deployment runners' security group. After validation, change the port 443 listener's forward action to the replacement target group. Retain the previous fleet and target group during the rollback window.

**Explanation:** Separate target groups keep both environments independently deployable and ready for traffic. The restricted validation listener allows testing through the existing ALB without exposing the replacement to production clients. Changing the production listener's forward action switches subsequent routing without DNS changes or target registration operations. Keeping the previous fleet available enables rollback by reversing the listener change; requests already in progress can finish on their original targets.

## Practice Blue-Green Deployment in a full exam

Questions on Blue-Green Deployment in each practice exam, with every answer option and an explanation for each:

- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 6 questions
- [SOA-C03](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate): 5 questions
- [AIB-C01 (beta)](https://blowstack.com/practice-exams/aws-certified-ai-business-strategist): 4 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 2 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 2 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 2 questions
- [SAA-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate): 2 questions
- [ANS-C01](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty): 1 question

## What is Blue-Green Deployment

Blue-green deployment separates preparing a release from exposing it to production traffic. The blue environment serves the current version while the green environment receives the replacement version. Engineers provision green, deploy the application and its configuration, validate readiness, and then redirect production traffic. The colors are labels rather than permanent roles: after a successful release, green becomes the active environment, and the previous environment can be retained temporarily or removed.

In the cloud, the environments might be separate groups of virtual machines, container task sets, or published serverless function versions. A load balancer, gateway, or function alias provides the traffic-switching mechanism. Infrastructure as code and versioned deployment artifacts help make the environments reproducible. This supports immutable infrastructure because engineers replace application instances rather than patching the running production fleet. However, blue-green deployment is a release strategy, while immutability is an infrastructure-management principle; neither automatically guarantees the other.

A practical web application release might create a replacement instance group from a new machine image, register it with a separate load-balancer target group, and run tests through a nonproduction listener. After checking authentication, dependency access, latency, and application behavior, the pipeline changes production routing. It drains existing connections where supported and retains the old group during an observation period. Long-lived connections, sticky sessions, caches, and DNS caching can delay complete transition, so a traffic switch is not necessarily instantaneous and does not guarantee zero downtime.

Database compatibility is often the most important rollback constraint. Both versions commonly share a production database, although separate databases are possible with a carefully designed synchronization strategy. Use backward-compatible schema changes, such as adding a nullable column before removing an old one in a later release. Returning traffic to blue does not undo writes, reverse external transactions, or restore deleted data. Session state should remain accessible to both versions, and background workers or scheduled jobs need coordination to avoid duplicate processing and incompatible writes.

CI/CD pipelines should automate environment creation, deployment, readiness checks, test execution, traffic switching, observation, and cleanup. Define rollback conditions using metrics such as error rate, latency, failed business transactions, or inference failures. A passing infrastructure health check is not proof of application correctness. Keep the old environment healthy and sufficiently provisioned during the rollback window, and confirm that rollback is actually possible after any data or configuration changes.

For AI and machine learning workloads, green can host a new model, inference container, or replacement AI platform integration. Validate input schemas, preprocessing, feature availability, representative datasets, output quality, inference latency, and cost per request before switching. Business continuity may require a fallback model or a manual process if the new system fails. Technical health alone cannot establish model quality; some business outcomes arrive too late for immediate automated rollback. Account for sensitive production data used in validation and for the temporary cost of duplicate inference capacity.

The main trade-offs are additional capacity, orchestration complexity, environmental parity, and state-management effort. Quotas must support overlapping environments, and green must handle expected production demand before cutover. Blue-green describes the coexistence of current and replacement environments; canary describes exposing a limited portion of traffic before broader rollout. They can be combined, although a classic blue-green cutover moves traffic in one step. Neither strategy replaces backups, multi-zone resilience, disaster recovery, or a tested operational recovery plan.

## Learn Blue-Green Deployment in lessons

15 short lessons on Blue-Green Deployment in 6 certification courses.

- AIB-C01 (beta): Blue-Green Deployment: preparing and switching release environments (Premium), https://app.blowstack.com/lessons/blue-green-deployment-preparing-and-switching-release-environments-aib-c01
- MLA-C02 (beta): Blue-Green Deployment: automated cutover and rollback (Premium), https://app.blowstack.com/lessons/blue-green-deployment-automated-cutover-and-rollback-mla-c02
- SAP-C03: Blue-Green Deployment: rollback-safe traffic cutovers (Premium), https://app.blowstack.com/lessons/blue-green-deployment-rollback-safe-traffic-cutovers-sap-c03
- SOA-C03: Blue-Green Deployment: switching release environments (Premium), https://app.blowstack.com/lessons/blue-green-deployment-switching-release-environments-soa-c03
- DOP-C02: Blue-Green Deployment: reversible traffic cutover (Premium), https://app.blowstack.com/lessons/blue-green-deployment-reversible-traffic-cutover-dop-c02
- SAA-C03: Blue-Green Deployment: replacing the production environment (Premium), https://app.blowstack.com/lessons/blue-green-deployment-replacing-the-production-environment-saa-c03
