AWS Certified DevOps Engineer – ProfessionalConfiguration Management and Infrastructure as CodeMedium

A startup is rapidly expanding its application on AWS and frequently deploys new features that require corresponding infrastructure changes. They use AWS CloudFormation for IaC. To minimize downtime during updates and ensure that new deployments are always tested before affecting production traffic, they want to implement a blue/green deployment strategy for their Amazon EC2 Auto Scaling groups. Which CloudFormation feature, when combined with an appropriate traffic shifting mechanism, can best facilitate this strategy?

  1. ACloudFormation Deployment Preferences with CodeDeploy for blue/green deployments.
  2. BUsing two separate CloudFormation stacks, one for blue and one for green.
  3. CCloudFormation Hooks to pause deployment and validate the new environment.
  4. DCloudFormation Custom Resources to manage blue/green traffic shifting.
Show answer & explanation

Correct answer: A. CloudFormation Deployment Preferences with CodeDeploy for blue/green deployments.

CloudFormation, in conjunction with AWS CodeDeploy, provides built-in capabilities for blue/green deployments for EC2/Auto Scaling Group based applications. CloudFormation's `AWS::CodeDeploy::DeploymentGroup` resource type allows defining `DeploymentStyle` and `BlueGreenDeploymentConfiguration` which orchestrates the creation of a new 'green' environment, traffic shifting, and termination of the 'blue' environment, directly supporting the requirement for minimal downtime and pre-testing.

Why the other options are wrong

  • B. Using two separate stacks for blue and green is a manual approach to blue/green. It lacks the integrated automation and traffic shifting orchestration provided by CodeDeploy with CloudFormation.
  • C. CloudFormation Hooks can pause deployments for validation, but they don't inherently manage the blue/green environment creation, traffic shifting, or rollback aspects of the deployment strategy.
  • D. While Custom Resources can extend CloudFormation, implementing a full blue/green strategy with traffic shifting this way would be complex and reinvent existing functionality.

CloudFormation with CodeDeploy Blue/Green

AWS CloudFormation can be integrated with AWS CodeDeploy to automate blue/green deployment strategies for applications running on Amazon EC2 instances and Auto Scaling groups.

  • Automates creation of new 'green' environment.
  • Orchestrates traffic shifting from 'blue' to 'green'.
  • Minimizes downtime and provides rollback capabilities.

Memory trick: CodeDeploy handles the traffic switch, CloudFormation builds the new road.

More Configuration Management and Infrastructure as Code questions