DOP-C02 Question 211
Select 2Your organization is using a CI/CD pipeline on AWS to deploy a serverless application built with AWS Lambda. The pipeline uses AWS CodePipeline, AWS CodeBuild, and AWS CloudFormation. Recently, deployments have been failing because of inconsistent Lambda function versions being deployed to production. How can you ensure that only the expected version of the Lambda function is deployed, while allowing for rollback if necessary?
- A
Use AWS CodeDeploy to deploy the Lambda function and enable traffic shifting with weighted aliases.
- B
Manually validate the Lambda function version in the CodePipeline stages.
- C
Enable versioning for the Lambda function and use aliases to refer to specific versions in the deployment process.
- D
Configure the CodeBuild project to output the Lambda function version and use that as an input to the next stage in CodePipeline.
- E
Use AWS CloudFormation to directly invoke the Lambda function during deployment for validation.
Show answer and explanation
Correct answers: A, C
Explanation
To ensure consistency and enable rollback during a Lambda function deployment, it is best to use AWS CodeDeploy with traffic shifting and weighted aliases, as this enables controlled deployment and rollback mechanisms. Additionally, enabling Lambda function versioning and using aliases ensures that specific versions are referenced in the deployment process, reducing the risk of deploying an incorrect version.
- A. Correct.
Correct. Using AWS CodeDeploy with traffic shifting and weighted aliases ensures deployment of the expected Lambda function version and supports rollback by controlling traffic between versions.
- B. Incorrect.
Incorrect. Manually validating versions is error-prone, inefficient, and not an automated solution suitable for a CI/CD pipeline.
- C. Correct.
Correct. Enabling versioning and using aliases allows you to specify and deploy exact versions of the Lambda function, mitigating the risk of deploying unintended versions.
- D. Incorrect.
Incorrect. While CodeBuild can output artifacts, managing Lambda function versions through CodeBuild alone does not solve the problem of inconsistent deployments or provide rollback capabilities.
- E. Incorrect.
Incorrect. Invoking the Lambda function for validation is unrelated to ensuring consistent versioning and does not address the issue of deploying the correct version.