Hands Free Canary with ALB Advanced Routing Rules
Canary deployments may seem like an advanced technique that requires a team of engineers to implement.
But with the new Advanced Request Routing for ALBs (Application Load Balancer), safely releasing new versions of your application straight into production has never been easier.
First, either create a new ALB or use an existing ALB and copy its DNS name.
Then, clone this repo https://github.com/ysawa0/alb-canary
And copy the DNS name to this section of
This repo will deploy a Lambda with a API Gateway endpoint that will redirect users to the ALB with a twist – it will add a
?id=$val GET parameter. Where $val will be an integer from 1 to 6.
It uses the Serverless Framework
# Install Serverless if you don't have it
Then run to deploy the Lambda and API Gateway
endpoint of the deployed API Gateway for later.
Now, we will set up routing rules that will mimic our “application”.
Add the rules below
It should now look like this.
Now, trying querying the API Gateway endpoint we deployed earlier.
1 out of 6 times, it should be bucketed into the canary rule.
curl -L https://dmkgpj2yxh.execute-api.us-east-1.amazonaws.com/qa/canary
That’s it! You’ve set up a canary deployment where 1/6 users are canaried.