AWS Certified DevOps Engineer – Professional (DOP-C02) — Question 110

A company has developed an AWS Lambda function that handles orders received through an API. The company is using AWS CodeDeploy to deploy the Lambda function as the final stage of a CI/CD pipeline.

A DevOps engineer has noticed there are intermittent failures of the ordering API for a few seconds after deployment. After some investigation, the DevOps engineer believes the failures are due to database changes not having fully propagated before the Lambda function is invoked.

How should the DevOps engineer overcome this?

Answer options

Correct answer: A

Explanation

The correct answer is A because the BeforeAllowTraffic hook ensures that any necessary database changes are fully applied before allowing traffic to the new version of the Lambda function, preventing failures. Option B is incorrect as the AfterAllowTraffic hook does not prevent traffic from reaching the function before the database is ready. Option C is not suitable because the BeforeInstall hook occurs before the new version is deployed, not during the traffic phase. Option D, while useful for validation, does not specifically wait for database readiness before allowing traffic.