AWS Serverless Migration: Blue/Green Strategy with API Gateway and Lambda

Migrating a Web Application from EC2 to API Gateway/Lambda Serverless Services

Prev Question Next Question

Question

You are working with several developers on migrating a web application from EC2 to API Gateway/Lambda serverless services.

Previously, the deployment of EC2 instances has used a blue/green strategy by attaching new auto-scaling groups to a dedicated Elastic Load Balancer.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - D.

AWS API Gateway has supported canary deployment.

In a canary release deployment, the API traffic is separated into a production release and a canary release with a user configured ratio.

Check the details on API Gateway documentation https://docs.aws.amazon.com/apigateway/latest/developerguide/canary-release.html.

Option A is incorrect: Because although CodeDeploy may work as a canary deployment mode, it is unnecessary.

API Gateway has a very easy method to set up a canary release.

Option B is incorrect: Because Elastic Beanstalk does not support canary deployment.

Instead, it supports a blue/green deployment by switching environment URLs.

Option C is incorrect: Because Lambda does not support a canary method when a Lambda function is published.

In this case, it should be done in API Gateway.

Option D is CORRECT: In API Gateway, canary settings can be found in the Stage.

The Stage's request distribution can be adjusted accordingly.

For example:

Resources:

GetHelloWorld:
Type: AWS: :Serverless: : Function
Properties:
Handler: index.get
Runtime: nodejs8.10
Role:
Fn::GetAtt:
- LambdaExecutionRole
- Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /
Method: get
LambdaExecutionRole:
Description: Creating service role in IAM for AWS Lambda
Type: AWS: :IAM::Role
Properties:
RoleName: !Sub 'CodeStar-${ProjectId}-Execution${Stage}'

The question is asking for the best way to implement canary deployment while migrating a web application from EC2 to API Gateway/Lambda serverless services. Canaray deployment is a deployment technique that gradually rolls out new code to a subset of users, allowing you to test new features and ensure that they are working correctly before making the new version available to all users.

Option A states that there is no straightforward way for API Gateway to implement canary deployment, and other services such as CodeDeploy are needed. This statement is incorrect because AWS does provide canary deployment options for API Gateway and Lambda.

Option B suggests using Elastic Beanstalk to deploy API Gateway/Lambda services as it supports a canary strategy when a new version is released. However, Elastic Beanstalk is not necessary as API Gateway and Lambda both offer canary deployment features.

Option C states that you can create a canary strategy in the AWS Lambda console by allocating 10% of the traffic to the new version when a new version is published. This statement is partially correct because it only addresses canary deployment for Lambda, not API Gateway.

Option D is the correct answer. You can configure a canary strategy in the relevant API Gateway stage, such as allocating 10% of the traffic to the new version. When a new API is deployed, select the stage with the enabled Canary. This strategy will allow you to test new features gradually and ensure they are working correctly before making them available to all users.

In summary, the best way to implement canary deployment while migrating a web application from EC2 to API Gateway/Lambda serverless services is to configure a canary strategy in the relevant API Gateway stage. Allocating a small portion of traffic to the new version will allow you to test new features gradually and ensure they are working correctly before making them available to all users.