As mentioned in the documentation for CloudFront Lambdas limitations
Environment variables aren't supported.
The reason I automated the functions generation was mainly to avoid human mistakes and centralize versioning of our A/B tests states.
When executed, build.sh
generates 3 functions to use on AWS lambdas@edge.
Functions names match AWS default naming to avoid confusion.
The build simply loads the variables from the configuration file (conf
) and replace the placeholders with the correct values.
Along with the function files, 2 other files are built:
build.json
containing the information of the current state.bookmarklet.js
a js function to use as a bookmarklet to alternate between experiments.
- Rename
conf.sample
toconf
and update its values. - run
./build.sh
. Functions will be automatically placed into thedist
folder. - Create the lmabda functions with the generated code.
- RUN TESTS!
- Done! 🍰
If you fork this repository and commit your dist
folder here's a shield.io badge to dynamically pull information from build.json
and expose the current bookmarklet on your README.md file. fancy right?!
- CF Origin should whitelist
source
header - CF Origin should whitelist the cookie for the given
cookie_name
. - Logs are region based. If you can't find them look into a closer region.
- When pointing to an S3 avoid
Host
onWhitelist Headers
If the bucket has a different name than the domain name
- Did I mention creating tests?
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.