DVA-C02 Question 214
Single answerYou are deploying a serverless application using AWS SAM (Serverless Application Model). During the deployment process, you want to ensure that the deployment creates a new version of your AWS Lambda function and automatically sets an alias to point to the most recent version. Which AWS SAM feature should you use to achieve this?
- A
AutoPublishAlias property in the AWS::Serverless::Function resource
- B
Versioning property in the AWS::Lambda::Alias resource
- C
DeploymentPreference property in the AWS::Serverless::Function resource
- D
UpdatePolicy attribute in the AWS::Serverless::Application resource
Show answer and explanation
Correct answer: A
Explanation
To automatically create a new version of an AWS Lambda function and set an alias to point to the most recent version during deployment, you should use the AutoPublishAlias property in the AWS::Serverless::Function resource. This feature simplifies managing Lambda function versions and aliases, which are often needed for advanced deployment strategies.
- A. Correct.
The AutoPublishAlias property in the AWS::Serverless::Function resource automatically creates a version of the AWS Lambda function and configures an alias that points to the published version. This is the correct feature for this scenario.
- B. Incorrect.
The Versioning property in the AWS::Lambda::Alias resource does not exist. This is an incorrect option as it refers to a non-existent property.
- C. Incorrect.
The DeploymentPreference property in the AWS::Serverless::Function resource is used for configuring deployment strategies for Lambda functions, such as canary or linear deployments. However, it does not create function versions or aliases automatically.
- D. Incorrect.
The UpdatePolicy attribute in the AWS::Serverless::Application resource is not valid. Update policies are typically used in CloudFormation for managing resources like Auto Scaling groups but are not related to Lambda function versioning or aliasing.