AWS protected S3 website with CloudFront using Lambda@Edge.

How to create a simple website on AWS, configuring the password-protected pages.

AWS protected S3 website with CloudFront using Lambda@Edge.

AWS protected by a password website served by Amazon CloudFront using Lambda@Edge.
AWS protected by a password website served by Amazon CloudFront using Lambda@Edge.

Inside the src/ folder you’ll find :
index.js => A node Auth file, to handle the website passwords.
s3_policy.json => The AWS policy to use with the AWS CLI.
– trust_policy.json => The Lambda@Edge policy to use with the AWS CLI.

Requirements:

  • S3 (for our static files)

  • CloudFront to serve the website.

  • Lamba@Edge to run the node.js

  • Extra:
    – Route 53 (for our domain DNS).
    – CloudFront (CDN — will serve our static files from various locations).
    – Certificate Manager (SSL certificate.
    – Secret Manager.
    – Keycloack/Okta to retrieve user/password.

    The complete guide from the repo sites:

    GitHub: https://github.com/garanet/protect-website-on-aws-cloudfront-lambda

    SourceForge: https://sourceforge.net/p/website-aws-cloudfront-lambda/code/ci/main/tree/

    A similar project is here: