Serve a custom error page from S3 through CloudFront while the ALB fault is fixed
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.)
Community Votes
100% of anonymous learners picked answer AE. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
CloudFront can be configured with a custom error response that maps the 502 status to an object in an S3 bucket, so the visitor gets the branded page while the transient origin fault is being resolved, and neither Route 53 nor the ALB needs to be reconfigured.
An ecommerce application behind an ALB occasionally returns a 502 Bad Gateway because the targets return malformed HTTP headers, and reloading immediately afterwards succeeds. While engineers investigate, visitors should see a custom error page instead of the default ALB error page.
Rewiring DNS or the ALB forwarding rule to a fallback web server. Those approaches change the request path for all traffic, add a component to operate, and the fault here is transient and application-level, so pointing production traffic at a different origin is a much larger change than adding an error response.
Community Discussion (8 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The problem is a transient 502 returned by the ALB, and the immediate need is only what the visitor sees during that window. Hosting a static custom error page in an Amazon S3 bucket is the cheapest way to have that page available, and it requires no change to the existing application or ALB configuration. A CloudFront custom error response is then configured to return that S3 object when CloudFront receives the 502 status, so visitors see the branded page. Because the fault is transient and the page reload succeeds, this is a presentation-layer measure that carries the least operational overhead, since no new compute, DNS, or health check logic has to be maintained.Why the Other Options Are Wrong
B: Modifying the ALB forwarding rule to point at a publicly accessible web server is a response to a health check failure metric, but the root cause here is malformed headers on specific requests rather than failing health checks, and changing the forwarding rule would redirect normal production traffic to a fallback server. D: Using the Elb.InternalError metric has the same two problems as B, since it changes the request path for all traffic and requires Lambda plus a fallback web server to operate. C: Adding health checks and a fallback target in Route 53 is aimed at resolving records when a target is unhealthy, which is not the failure described, and it adds DNS-level complexity for a page-rendering requirement.Community Comment Notes
The community voted 100 to 0 for A and E, and the top-voted comment linked the CloudFront documentation for generating custom error responses. A commenter also noted this is the same question as an earlier item in the same practice set, which is consistent with the fully unanimous answer.Official Reference
Related Analysis
Practice All SAP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full SAP-C02 Practice Test →