SAP-C02 practice question 12 of 35

A retail company is operating its ecommerce application on AWS. The application runs on Amazon EC2 instances behind an Application Load Balancer…

Full set: 689 questions

Domain Continuous Improvement for Existing Solutions

A retail company is operating its ecommerce application on AWS. The application runs on Amazon EC2 instances behind an Application Load Balancer (ALB). The company uses an Amazon RDS DB instance as the database backend. Amazon CloudFront is configured with one origin that points to the ALB. Static content is cached. Amazon Route 53 is used to host all public zones. After an update of the application, the ALB occasionally returns a 502 status code (Bad Gateway) error. The root cause is malformed HTTP headers that are returned to the ALB. The webpage returns successfully when a solutions architect reloads the webpage immediately after the error occurs. While the company is working on the problem, the solutions architect needs to provide a custom error page instead of the standard ALB error page to visitors. Which combination of steps will meet this requirement with the LEAST amount of operational overhead? (Choose two.)
Answer options
A: Create an Amazon S3 bucket. Configure the S3 bucket to host a static webpage. Upload the custom error pages to Amazon S3. Correct answer
B: Create an Amazon CloudWatch alarm to invoke an AWS Lambda function if the ALB health check response Target.FailedHealthChecks is greater than 0. Configure the Lambda function to modify the forwarding rule at the ALB to point to a publicly accessible web server.
C: Modify the existing Amazon Route 53 records by adding health checks. Configure a fallback target if the health check fails. Modify DNS records to point to a publicly accessible webpage.
D: Create an Amazon CloudWatch alarm to invoke an AWS Lambda function if the ALB health check response Elb.InternalError is greater than 0. Configure the Lambda function to modify the forwarding rule at the ALB to point to a public accessible web server.
E: Add a custom error response by configuring a CloudFront custom error page. Modify DNS records to point to a publicly accessible web page. Correct answer
Correct Answer:
A. Create an Amazon S3 bucket. Configure the S3 bucket to host a static webpage. Upload the custom error pages to Amazon S3.; E. Add a custom error response by configuring a CloudFront custom error page. Modify DNS records to point to a publicly accessible web page.
Explanation

The most efficient and least operationally intensive solution is to leverage the existing Amazon CloudFront distribution. This can be achieved by using CloudFront's native custom error page functionality. The process involves two main steps:
1. First, a custom error page (e.g., an HTML file) must be created and made publicly accessible. The standard, low-cost method for this is to upload the file to an Amazon S3 bucket and configure the bucket for static website hosting (Option A).
2. Second, the CloudFront distribution must be configured to intercept the specific 502 Bad Gateway HTTP status code when it is returned by the origin (the ALB). Instead of passing the error to the user, CloudFront will fetch and serve the custom error page from the S3 bucket (Option E). This approach is ideal because it handles errors on a per-request basis, does not impact healthy traffic, and is a simple configuration change with minimal overhead.

Why Incorrect

B. Create an Amazon CloudWatch alarm to invoke an AWS Lambda function... This is overly complex and disruptive. Modifying ALB rules via Lambda is a slow, stateful change that would redirect all users, not just the one who received the error.
C. Modify the existing Amazon Route 53 records by adding health checks... Route 53 DNS failover is designed for endpoint failures, not for intermittent, per-request application errors. The ALB endpoint itself is likely healthy, so health checks would not fail.
D. Create an Amazon CloudWatch alarm to invoke an AWS Lambda function... Similar to option B, this is an inappropriate use of Lambda and ALB rule modification. It is not designed for real-time, per-request error handling and has high operational overhead. ---

References

1. Amazon CloudFront Developer Guide - Serving custom error pages: This document explicitly describes the required functionality. It states

"You can have CloudFront return a custom error page when your origin server returns an HTTP 4xx or 5xx status code to CloudFront... Instead of returning the object

CloudFront can return a custom error page that you provide." This supports using CloudFront to handle the 502 error (Option E).

Source: AWS Documentation

Amazon CloudFront Developer Guide

"Configuring custom error responses".

2. Amazon S3 User Guide - Hosting a static website using Amazon S3: This guide details the process of configuring an S3 bucket to serve static content like HTML pages over HTTP

which is the standard prerequisite for serving a custom error page via CloudFront. This supports the creation and hosting of the error page (Option A).

Source: AWS Documentation

Amazon S3 User Guide

"Hosting a static website using Amazon S3".

3. Amazon Route 53 Developer Guide - Configuring DNS failover: This document explains that DNS failover works by routing traffic away from an unhealthy resource based on the status of a health check. This mechanism is not suitable for transient

per-request errors where the endpoint itself remains healthy and available. This confirms why Option C is incorrect.

Source: AWS Documentation

Amazon Route 53 Developer Guide

"Concepts

" section "Health checks and DNS failover".

Scroll to Top