Search code examples
amazon-web-servicesamazon-ec2amazon-cloudfront

AWS replace EC2 with CloudFront


I have a domain dev-www.myexample.de hosted via AWS EC2 and a Load Balancer. I want to replace this configuration with an S3 bucket + CloudFront and keep same domain name.

The only possible way I could find was destroying my EC2 instance and Route 53 and then deploy my CloudFront and domain and this works fine.

However, I want to show a 503 page for all traffic that comes while my EC2 instance is down and before my CloudFront and S3 bucket are ready to use. Any idea how I can do that?


Solution

  • You can create your Amazon S3 bucket and Amazon CloudFront distribution before changing the DNS configuration. This gives you an opportunity to ensure that it is working correctly.

    Then, you can change the Route 53 configuration to point to CloudFront instead of the Load Balancer. It will take some time for this change to propagate throughout the Internet, during which cached queries will continue to go to the Load Balancer but new DNS lookups will go to CloudFront. If you have the same content in both locations, there should not be a need to display any notice.

    Please note that only static content can be served from Amazon S3, so if you had any back-end logic in your Amazon EC2 servers, it would not be possible to continue providing it with CloudFront + S3.