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

+1 vote

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,280 points

1 answer to this question.

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,670 points

Related Questions In AWS

0 votes
1 answer

How to get the contents of a folder in an AWS CodeCommit repository?

Hi@akhtar, The following get-folder example demonstrates how to get the ...READ MORE

answered Nov 25, 2020 in AWS by MD
• 95,440 points

edited Aug 4, 2023 by Khan Sarfaraz 2,404 views
0 votes
0 answers
0 votes
1 answer

how to get the list of aws services i am used in aws my account by using the lambda function

Hi@shalk, You can create a session in your ...READ MORE

answered Sep 24, 2020 in AWS by MD
• 95,440 points
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
+2 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
• 58,090 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,670 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP