Lamnda@Edge function which will protect static websites hosted in S3 and served by Cloudfront. Visitors to the sites will be required to authenticate with Auth0 before they can access the site.
This one lambda is meant to protect multiple sites
- Edit
config.js
and add the new Auth0 client (and possibly new Auth0 tenant) to theauth0Tenants
variable. - Edit
config.js
and add the new hostname to thehostMapping
variable (telling the lambda which auth0 client to use for this site) - Run
yarn
to install dependencies if you have not already - Run
yarn run build
to buildpackage.zip
- Login to AWS, goto Lambda console and locate the
cf-trigger-auth0
lambda method in the US East-1 (N. Virginia) Region - Select the Lambda LATEST version and specify you wish to upload a new zip
- Upload the package.zip and save.
- Choose "Publish New Version" from Actions dropdown
- Select the new version you published and add a
Cloudfront
trigger. - Configure the trigger by specifying the Cloudfront distribution you wish to protect and setting event trigger to Viewer Request.
- Click Add
- If you want to update multiple Cloudfront distributions for your change, repeat previous 2 steps for each distribution
- When finished, click Save.
- Wait a few minutes for the Lambda to be replicated
- See if it works