Download the PHP package happyr/bref-hook-handler without Composer
On this page you can find all versions of the php package happyr/bref-hook-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download happyr/bref-hook-handler
More information about happyr/bref-hook-handler
Files in happyr/bref-hook-handler
Package bref-hook-handler
Short Description Simple way to handle Bref Lambda hooks
License MIT
Informations about the package bref-hook-handler
Bref Hook Handler
This small library helps you to make sure the new version of your lambda application is actually working before you directing traffic it. It makes it simple to run a "PreTrafficHook".
Install
We also need serverless-plugin-canary-deployments
from
davidgf:
Configure
The idea is to create a new lambda function that can verify that everything is working. When we are sure all things are green, we will signal CodeDeploy to allow real traffic.
Example serverless.yml
Example prehook.php
The prehook script is where you start your application kernel, test writing to
the database, dispatch a message on the queue etc etc. If you use the HookHandler
it will automatically communicate back to CodeDeploy.
One can of course add as much or little logic as one need.
Making HTTP requests
In the example above we are making a HTTP request to our homepage. We cannot use
API Gateway because it does not route traffic to the new Lambda version. So we invoke
the lambda version directly with parameters that look like it comes from ApiGateway.
The ApiGatewayFaker
helps us with that.
This is the only reason why we need to configure lambda:InvokeFunction
in the
IAM Role.
Note
If the prehook.php does not make a request to CodeDeploy then the deployment will hey stuck at "Checking Stack update progress". This is a good thing. This ensures that the prehook script always reports "Succeeded".
Check the CloudWatch logs if this happens.
Cool, lets to canary deployments!
It is tempting to change the deploymentSettings.type
to something else but "AllAtOnce"
to expose your new version to 10% of the requests first... But it might not be optimal.
Consider reading this article first: https://lumigo.io/blog/canary-deployment-for-aws-lambda/
All versions of bref-hook-handler with dependencies
ext-json Version *
async-aws/code-deploy Version ^1.0
async-aws/lambda Version ^1.0
bref/bref Version ^0.5.20 || ^1.0