Question

Difficulty: HardDeployment Strategies

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?

  1. Configure the AutoPublishAlias property under the Serverless Function resource to define the alias that will receive the shifted traffic.Answer
  2. Under DeploymentPreference, set the Type to Linear10PercentEvery2Minutes, list the rollback alarms under Alarms, and define the PreTraffic and PostTraffic lifecycle hooks.Answer
  3. C
    Under DeploymentPreference, set the Type to Canary10PercentEvery2Minutes and define the hooks under BeforeAllowTraffic and AfterAllowTraffic.
  4. D
    Define a custom CodeDeploy deployment configuration named CodeDeployDefault.LambdaLinear10PercentEvery2Minutes in the Resources section of the template.
  5. E
    Under 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

1
Enable traffic shifting support by defining an alias configuration.
Define the AutoPublishAlias property under the AWS::Serverless::Function resource.
AWS SAM cannot perform gradual deployment unless a function alias is defined to shift traffic between the old and new versions.
2
Select the correct linear deployment type configuration.
Set the Type under DeploymentPreference to Linear10PercentEvery2Minutes.
This built-in configuration matches the requirement of shifting 10% of the traffic every 2 minutes.
3
Link safety controls and lifecycle hooks for validation.
Reference the CloudWatch alarms under Alarms and the Lambda validation functions under the PreTraffic and PostTraffic hook properties.
Alarms trigger automatic rollback during the deployment, and hooks run integration tests before traffic shifting starts and cleanup after traffic shifting completes.

Key Concept

Configuring AWS SAM safe deployments (DeploymentPreference) using built-in CodeDeploy types, aliases, alarms, and lifecycle hooks.
Estimated Time:2m 30s
Rate this question