Invoke a Lambda on every successful and failed pipeline run to publish CloudWatch custom metrics and a dashboard

Answer Correct answer: B — invoke a Lambda on every successful and failed pipeline run to publish CloudWatch custom metrics for a dashboard.

A company wants to decrease the time it takes to develop new features. The company uses AWS CodeBuild and AWS CodeDeploy to build and deploy its applications. The company uses AWS CodePipeline to deploy each microservice with its own CI/CD pipeline. The company needs more visibility into the average time between the release of new features and the average time to recover after a failed deployment. Which solution will provide this visibility with the LEAST configuration effort?

  1. Program an AWS Lambda function that creates Amazon CloudWatch custom metrics with information about successful runs and failed runs for each pipeline. Create an Amazon EventBridge rule to invoke the Lambda function every 5 minutes. Use the metrics to build a CloudWatch dashboard.
  2. Program an AWS Lambda function that creates Amazon CloudWatch custom metrics with information about successful runs and failed runs for each pipeline. Create an Amazon EventBridge rule to invoke the Lambda function after every successful run and after every failed run. Use the metrics to build a CloudWatch dashboard. Correct Answer
  3. Program an AWS Lambda function that writes information about successful runs and failed runs to Amazon DynamoDB. Create an Amazon EventBridge rule to invoke the Lambda function after every successful run and after every failed run. Build an Amazon QuickSight dashboard to show the information from DynamoDB.
  4. Program an AWS Lambda function that writes information about successful runs and failed runs to Amazon DynamoDB. Create an Amazon EventBridge rule to invoke the Lambda function every 5 minutes. Build an Amazon QuickSight dashboard to show the information from DynamoDB.

Community Votes

B
100%

100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

Event-driven invocation on pipeline state change is what makes the metrics accurate and the configuration minimal, because every run is captured as it happens rather than sampled on a schedule (B). Publishing to CloudWatch custom metrics and charting them on a CloudWatch dashboard keeps everything inside CloudWatch with no database or business-intelligence service to provision (B). Options A and D use a five-minute schedule, which both delays the data and can miss or double-count runs, and options C and D add DynamoDB plus QuickSight, which is substantially more configuration for the same visibility.

The team needs deployment frequency and recovery time per microservice with the least configuration. CodePipeline emits success and failure state change events, so an EventBridge rule matched to those events invokes a Lambda function that publishes CloudWatch custom metrics recording each successful and failed run per pipeline. A CloudWatch dashboard built on those metrics then shows both the rate of releases and the mean time to recover after a failed deployment, with no polling infrastructure and no separate database.

Invoking the Lambda function every five minutes with a scheduled rule (A and D) — a schedule samples the pipeline state rather than reacting to each run, so metrics lag by up to five minutes, short runs may be missed entirely, and no run is recorded at the moment it occurs. Writing results to DynamoDB and building an Amazon QuickSight dashboard (C and D) — this introduces a database to provision and a business-intelligence dashboard with its own data-source configuration, which is far more setup than publishing custom metrics that CloudWatch can chart directly. trungtd made exactly this point about C and D.

Community Discussion (4 comments)

limelight04 👍 2 Selected: B
B is the correct answer
jamesf 👍 3 Selected: B
B is most simple and direct with LEAST configuration effort.
tgv 👍 2
---> B
trungtd 👍 4 Selected: B
A. Invoking the Lambda function every 5 minutes is less efficient compared to event-driven invocation B. provides the needed visibility with minimal configuration effort C & D. Using DynamoDB and QuickSight involves more configuration

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

CodePipeline emits events when each pipeline run succeeds or fails, so an EventBridge rule matched to those state change events can invoke the Lambda function after every successful run and every failed run, giving one invocation per run with no polling (B). The function publishes CloudWatch custom metrics capturing that information per pipeline, and because both required measures derive from those metrics, a CloudWatch dashboard presents the release cadence and the mean time to recover after a failed deployment using services already in use, with no additional data store. This is the least-configuration path because every component is event-driven and stays within CloudWatch (B).

Why the Other Options Are Wrong

A uses the same Lambda and CloudWatch metrics but invokes the function every five minutes through a scheduled EventBridge rule. A schedule samples state rather than reacting to each pipeline run, so metrics appear up to five minutes late, very short runs may never be sampled, and the resulting data cannot be relied on for either deployment frequency or recovery time; trungtd identified this as less efficient than event-driven invocation. D combines that same five-minute schedule with DynamoDB and QuickSight, adding both the sampling problem and the extra infrastructure. C uses EventBridge correctly on pipeline success and failure events but writes the results to DynamoDB and builds an Amazon QuickSight dashboard to display them, which requires provisioning a table and configuring a business-intelligence data source and dashboard, far more configuration than publishing custom metrics that CloudWatch charts natively. B is the correct answer.

Community Comment Notes

Community voted B unanimously. jamesf identified B as the simplest and most direct with the least configuration effort. trungtd explained that the five-minute invocation in A is less efficient than event-driven invocation, that B provides the needed visibility with minimal configuration effort, and that C and D add DynamoDB and QuickSight overhead. limelight04 and tgv confirmed B without further qualification. No alternative received support.

Official Reference

Related Analysis

Practice All DOP-C02 Questions

Access 85 questions with complete answers and detailed explanations.

View Full DOP-C02 Practice Test →

← Back to DOP-C02 Study Guide