A developer is using AWS Serverless Application Model (SAM) to deploy updates to a critical Lambda function. The deployment must satisfy the following constraints:
- Traffic must be shifted from the old version to the new version gradually, in increments of 10% every 2 minutes.
- The deployment must automatically roll back if the execution error rate or latency metrics exceed predefined thresholds.
- Integration test suites must run before traffic starts shifting, and a cleanup script must run after all traffic has shifted to the new version.
Which TWO configurations must the developer specify in the AWS SAM template to satisfy these requirements?
- Configure the AutoPublishAlias property under the Serverless Function resource to define the alias that will receive the shifted traffic.Answer
- Under DeploymentPreference, set the Type to Linear10PercentEvery2Minutes, list the rollback alarms under Alarms, and define the PreTraffic and PostTraffic lifecycle hooks.Answer
- CUnder DeploymentPreference, set the Type to Canary10PercentEvery2Minutes and define the hooks under BeforeAllowTraffic and AfterAllowTraffic.
- DDefine a custom CodeDeploy deployment configuration named CodeDeployDefault.LambdaLinear10PercentEvery2Minutes in the Resources section of the template.
- EUnder DeploymentPreference, set the Type to AllAtOnce and configure a custom AWS CodePipeline action to rollback the stack if the CloudWatch alarms transition to the ALARM state.
Answer
The developer must specify the AutoPublishAlias property under the Serverless Function resource to define the alias for traffic routing, and configure the DeploymentPreference section with Type: Linear10PercentEvery2Minutes along with the rollback alarms and the PreTraffic and PostTraffic hooks.
To perform gradual traffic shifting with AWS SAM, the function must have AutoPublishAlias enabled. In addition, the deployment strategy must be specified via DeploymentPreference with Type: Linear10PercentEvery2Minutes to shift traffic by 10% every 2 minutes. The template must also reference CloudWatch alarms for automated rollback and specify PreTraffic and PostTraffic hooks to execute validation tests and cleanup operations.
Step-by-Step Solution
Key Concept
Configuring AWS SAM safe deployments (DeploymentPreference) using built-in CodeDeploy types, aliases, alarms, and lifecycle hooks.
Estimated Time:2m 30s