Categories: Development

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:

    Share

    Recent Posts

    FastAPI, SQLAlchemy & Uvicorn

    A FastAPI, SQLAlchemy & Uvicorn to fetch a Google Sheet A FastAPI, SQLAlchemy & Uvicorn to fetch a Google Sheet… Read More

    Client TrueNas & Ldap with python Flask

    A webtool in Python Flask that creates an LDAP user and his TrueNAS shares pool in ISCSI or NFS. There… Read More

    Simple Terraform configuration

    A Terraform configuration that provisions the following infrastructure: A VPC with: Public subnets for external resources. Private subnets for internal… Read More