AWS Certified Developer - Associate Exam: Shifting Application Traffic Between Lambda Functions

Answer the Question: Shifting Application Traffic Between Lambda Functions

Prev Question Next Question

Question

Your application currently points to several Lambda functions in AWS.

A change is being made to one of the Lambda functions.

You need to ensure that application traffic is shifted slowly from one Lambda function to the other.

Which of the following steps would you carry out? Select 2 Options.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Answer - A and B.

This is mentioned in the AWS Documentation.

By default, an alias points to a single Lambda function version.

When the alias is updated to point to a different function version, incoming request traffic instantly points to the updated version.

This exposes that alias to any potential instabilities introduced by the new version.

To minimize this impact, you can implement the routing-config parameter of the Lambda alias that allows you to point to two different versions of the Lambda function and dictate what percentage of incoming traffic is sent to each version.

Options C and D are incorrect since you need to use ALIAS for this purpose.

Option E is incorrect because A & B are the correct ways to achieve the requirement.

For more information on shifting traffic using ALIAS, please refer to the below URL-

https://docs.aws.amazon.com/lambda/latest/dg/lambda-traffic-shifting-using-aliases.html

To ensure a slow traffic shift from one Lambda function to another, you can use the AWS Lambda's built-in traffic shifting feature, which allows you to gradually shift traffic from one function version to another, or from one alias to another, using weighted percentages.

To implement the traffic shifting, you can perform the following steps:

  1. Create a new version of the Lambda function that you want to shift traffic to. You can create a new version from the AWS Lambda console or by using the AWS CLI with the create-function command and the --publish parameter.

Example CLI command to create a new version of a Lambda function:

css
aws lambda create-function --function-name my-function \ --code S3Bucket=my-bucket,S3Key=my-code.zip --runtime nodejs14.x \ --handler index.handler --role my-execution-role --publish
  1. Create an alias for the new version. An alias is a pointer to a specific version of a function. You can create an alias using the AWS Lambda console or by using the AWS CLI with the create-alias command.

Example CLI command to create an alias for a Lambda function:

r
aws lambda create-alias --function-name my-function \ --name prod --function-version 2
  1. Update the existing alias to gradually shift traffic to the new version. You can update the alias using the AWS Lambda console or by using the AWS CLI with the update-alias command and the --routing-config parameter.

Example CLI command to update an alias with a routing configuration:

css
aws lambda update-alias --function-name my-function \ --name prod --routing-config '{"AdditionalVersionWeights":{"3":0.5}}'

The --routing-config parameter specifies the percentage of traffic that should be shifted to the new version (in this case, 50%). You can specify additional version weights to gradually shift traffic to multiple versions.

Overall, to gradually shift traffic from one Lambda function to another, you need to create a new version of the function, create an alias for the new version, and update the existing alias with a routing configuration to gradually shift traffic to the new version.