nerdexam
Amazon

DOP-C02 · Question #106

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

The correct answer is A. Add a BeforeAllowTraffic hook to the AppSpec file that tests and waits for any necessary database. Explanation Option A is correct because the BeforeAllowTraffic hook in a CodeDeploy AppSpec file executes before any traffic is shifted to the new Lambda function version, making it the ideal place to run validation logic that checks and waits for database changes to fully propag

Submitted by brentm· Mar 6, 2026SDLC Automation

Question

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?

Options

  • AAdd a BeforeAllowTraffic hook to the AppSpec file that tests and waits for any necessary database
  • BAdd an AfterAllowTraffic hook to the AppSpec file that forces traffic to wait for any pending database
  • CAdd a BeforeInstall hook to the AppSpec file that tests and waits for any necessary database changes
  • DAdd a ValidateService hook to the AppSpec file that inspects incoming traffic and rejects the payload if

How the community answered

(27 responses)
  • A
    85% (23)
  • B
    7% (2)
  • C
    4% (1)
  • D
    4% (1)

Explanation

Explanation

Option A is correct because the BeforeAllowTraffic hook in a CodeDeploy AppSpec file executes before any traffic is shifted to the new Lambda function version, making it the ideal place to run validation logic that checks and waits for database changes to fully propagate - ensuring the function is only invoked once the environment is ready.

Option B (AfterAllowTraffic) is wrong because this hook runs after traffic has already been routed to the new version, meaning users would still experience failures during the window before the hook completes. Option C (BeforeInstall) is a hook used in EC2/on-premises deployments and is not valid for Lambda deployments in CodeDeploy. Option D (ValidateService) is not a real CodeDeploy lifecycle hook - it's a distractor designed to sound plausible.

Memory Tip: Think of the traffic flow as a gate - BeforeAllowTraffic = check before opening the gate, AfterAllowTraffic = check after the gate is already open. For Lambda deployments, you always want to validate before the gate opens to prevent real users from hitting errors.

Topics

#AWS CodeDeploy#Lambda Deployment#Deployment Hooks#CI/CD

Community Discussion

No community discussion yet for this question.

Full DOP-C02 Practice