Deploy this project to AWS to run an A/B test which returns one of 2 web pages for a single HTTP request.
npm i serverless@3.39.0 -g
npm i
serverless deploy --verbose
Once deployed, look for ABTestURL
in the output.
Now:
- Hit the URL in a browser.
- See one of two webpages, chosen randomly.
- Refresh and always get the same web page.
If you delete your cookies, you'll get another randomly chosen web page.
Enjoy!
You must first do some manual clean up for the automated deletion to succeed.
Log into the AWS CloudFront console and delete the Lambda function associations for the default behaviour.
- Select your CloudFront distribution
- Go to Behaviours
- Select Default then Edit
- Scroll to the bottom and under Function associations change every Function type to No association
- Save changes
Wait 30 minutes then on the command line run serverless remove
.