Last active
January 18, 2019 22:01
-
-
Save talawahtech/fb56811adeee792455fa91983d6950f3 to your computer and use it in GitHub Desktop.
CloudFormation snippet for quickly putting a site behind a Load Balancer "under maintenance"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: | |
UnderMaintenance: | |
Description: 'Returns a static "under maintenance" page and a 503 response code. ONLY WORKS WITH ALB' | |
Type: String | |
Default: 'NO' | |
AllowedValues: ['YES', 'NO'] | |
Conditions: | |
UnderMaintenance: !Equals [!Ref 'UnderMaintenance', 'YES'] | |
Resources: | |
UnderMaintenanceListenerRule: | |
Condition: UnderMaintenance | |
Type: AWS::ElasticLoadBalancingV2::ListenerRule | |
Properties: | |
ListenerArn: !Ref YOUR LOAD BALANCER LISTENER | |
Priority: 1 # Highest priority | |
Conditions: | |
- Field: path-pattern | |
Values: ['*'] # Catch-all | |
Actions: | |
- Type: 'fixed-response' | |
FixedResponseConfig: | |
StatusCode: 503 | |
ContentType: 'text/html' | |
MessageBody: > | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> | |
<title>Under Maintenance</title> | |
<style> | |
html, body{ height: 100%; } | |
body{display: flex; align-items: center; margin: 0 0.8rem; background:linear-gradient(45deg, #292561, #122040);} | |
main{width: 100%; text-align: center; color:#fff; font-family: "Open Sans", sans-serif;} | |
h1{margin: 0; font-size: 3.5rem;} | |
p{margin-top: 1rem; font-size: 1.5rem;} | |
@media screen and (max-width: 480px) {h1 {font-size: 2rem;} p {font-size: 1.2rem;} } | |
</style> | |
</head> | |
<body> | |
<main> | |
<h1>Under Maintenance 🚧</h1> | |
<p>We apologize for the inconvenience. We'll be back online as soon as possible!</p> | |
</main> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment