How to put up a maintenance page in AWS when I want to deploy the new versions of own applications behind an ELB?

0 votes

How do I put up a maintenance page for AWS when my instances are behind an ELB?

I want to have the ELB route traffic to the maintenance instances while the new auto-scaled instances are popping up, and only "flip over" to the new instances once they're fully up. I use auto-scaling to bring existing instances down and new instances, which have the new code, up.

The situations is that I am trying to avoid having the ELB serve both traffic to new EC2 instances while also serving up the maintenance page. As I don't have these sticky sessions enabled, I want to prevent the user from being flipped back and forth between the maintenance-mode page and the application deployed in an EC2 instance. I also just can't scale up (say from 4 to 6 instances and then back to 4) to introduce the new instances because the code modifications might involve database alterations which would be breaking transitions for the old code as well.

Apr 13, 2018 in AWS by Flying geek
• 3,130 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can try these steps to put up the maintenance page: 

  • Replicate your EB environment to create another one, call it something like app-environment-maintenance, for instance.
  • Change the configuration for autoscaling and set the min and max servers both to zero. This won't cost you any EC2 servers and the environment will turn grey and sit on your list.
  • This is a requirement, but we use CloudFront, as many people will for HTTPS, etc. CloudFront has error pages.
  • Create a new S3 website hosting bucket with your error pages. Consider creating separate files for response codes, 503, etc. See #6 for directory requirements and routes.
  • Add the S3 bucket to your CloudFront distribution.
  • Add a new behavior to your CloudFront distribution for a route like /error/*.
  • Setup error pages in Cloudfront to handle 503 response codes and point it to your S3 bucket route, like /error/503-error.html

Finally, you can use the AWS CLI to now swap the environment CNAME to take your main environment into maintenance mode. For instance:

aws elasticbeanstalk swap-environment-cnames \

    --profile "$awsProfile" \

    --region "$awsRegion" \

    --output text \

    --source-environment-name api-prod 

  --destination-environment-name api-prod-maintenance

  • This would swap your api-prod environment into maintenance mode. It would cause the ELB to throw a 503 since there aren't any running EC2 instances and then CloudFront will catch the 503 and return your respective 503 error page.
  • This is it, I know there are quite a few steps and I tried a lot of the suggested options out there including Route53 and many more, but all of these have issues with how they work with ELBs and CloudFront, etc.
answered Apr 13, 2018 by Cloud gunner
• 4,240 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

refer this link You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 56,140 points
0 votes
1 answer

How to skip headers when reading a CSV file in S3 and creating a table in AWS Athena?

This is a known deficiency. The best ...READ MORE

answered Sep 4, 2018 in AWS by Archana
• 4,090 points
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,140 points
0 votes
1 answer

Want to use an AWS Cognito User Pool without putting a password(for an easier approach)

Currently, AWS Cognito is not supporting passwordless ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,240 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.