This is a Lambda@Edge function that is used to customize response body for Single Page Application (SPA) served through Cloudfront.
It allows returning static html for social sites (including Facebook, WhatsApp, Twitter) for rich social sharing (due to the nature of Single Page Application - SPA).
- npm - can be installed via Homebrew
brew install node
- gulp-cli -
npm install gulp-cli -g
- Update the externalApi in the environment-config.json.
npm install
gulp default --env {environment}
Environment: dev/ prodarchive.zip
will be created in the root folder and can be deployed to AWS Lambda
- Environment variables are not supported for the Lambda@Edge deployed to Cloudfront. Therefore, gulp is used to automate the task of replacing the env variables and also create the artifact for uploading. Or AWS System Manager Parameter Store can be used.
- AWS Lambda can only be deployed to (N. Virginia) Region.
- Only Node.js runtime supported at the time when this is written.
- Timeout of the lambda can be configured to 5 seconds.
- Configure the Lambda@Function association's event type as
Viewer Request