If you host apps on AWS there are managed services helping you release changes gradually avoiding risky “big bang” deployments. For server-less applications you can use lambda version aliases, for ECS/EC2/Beanstalk there is blue-green deployment with CodeDeploy.

But those tools address back-end deployments only.

What if you wanted to apply same pattern to release static front-end hosted on S3? Below is a recipe to achieve just that!

Ingredients:

  • 1 CloudFront distribution
  • 2 Lambda functions (request + response)
  • 2 S3 Buckets (current + next versions)
  • 1 Cookie

The end result will look delicious:

It may look complex at first but it’s just a few resources created with Cloudformation. In fact, you can set this infra up in your AWS account by just clicking the button below:

The CF template has 2 parameters:

  • ReleaseName. Unique identifier of the version we are currently releasing, for example “v2”
  • ReleaseWeight. Number between 1 and 100 specifying to which percentage of users we are rolling the current release out. These users will be selected randomly and the user version state will be saved in a cookie.

#lambda #cloud-computing #devops #aws #web apps

Deployment of Web Apps with CloudFront, S3, Lambda and Cookies
3.70 GEEK