Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

S3 static website /w bluegreen deployment

I'm having difficulty providing a bluegreen for my s3 static website. I publish a version of the website in a given bucket and it is exposed at:

  • a Cloudfront distribution
  • then on a Route 53
  • and yet another CDN (corporate, which resolves the DNS) to reach the internet.

I've trying some "compute" solutions, like ALB, but I'm not successful.

The main issue of my difficulty is the long DNS replication time when I update CloudFront with a new address, making it difficult to rollback a future version to the old one (considering using different buckets for this publication).

Has anyone been through this or have any idea how to solve this?

like image 440
Hide Watanabe Avatar asked Feb 02 '20 20:02

Hide Watanabe


People also ask

Can static websites created with Amazon S3 be interactive?

You can use Amazon S3 to host a static website. On a static website, individual webpages include static content. They might also contain client-side scripts. By contrast, a dynamic website relies on server-side processing, including server-side scripts, such as PHP, JSP, or ASP.NET.

Which S3 feature can be used to host static website?

To enable static website hosting Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to enable static website hosting for. Choose Properties. Under Static website hosting, choose Edit.

What is blue green deployments in AWS?

A blue/green deployment is a deployment strategy in which you create two separate, but identical environments. One environment (blue) is running the current application version and one environment (green) is running the new application version.


3 Answers

AWS recommends that you create different CloudFront distributions for each blue/green variant, each with its own DNS.

From the Hosting Static Websites on AWS prescriptive guidance:

Different CloudFront distributions can point to the same Amazon S3 bucket so there is no need to have multiple S3 buckets. Each variation [A/B or blue/green] would store its assets under different folders in the same S3 bucket. Configure the CloudFront behaviors to point to the respective Amazon S3 folders for each A/B or blue/green variation.

The other key part of this strategy is an Amazon Route 53 feature called weighted routing. Weighted routing allows you to associate multiple resources with a single DNS name and dynamically resolve DNS based on their relative assigned weights. So if you want to split your traffic 70/30 for an A/B test, set the relative weights to be 70 and 30. For blue/green deployments, an automation script can call the Amazon Route 53 API to gradually shift the relative weights from blue to green after automated tests validate that the green version is healthy.

like image 79
jarmod Avatar answered Oct 24 '22 15:10

jarmod


Hosting Static Websites on AWS - It's 2016 year whitepaper. It relies on non-working examples that don't work. You can't just setup two cloudfront distributions to serve the same CNAME for dns switching.

Another way is to do green/blue logic in lambda edge.

like image 25
Евгений Петрович Avatar answered Oct 24 '22 14:10

Евгений Петрович


You can do blue/green or gradual deployment with a single Cloudfront distribution, 2 S3 buckets and Lambda@Edge. You can find a ready-to-use cloudformation template that does this here.

like image 1
dennis Avatar answered Oct 24 '22 14:10

dennis