This project uses Serverless framework and AWS Lambda
to drop index.html
to your S3 bucket whenever you upload, rename or remove
any file.
Dark theme is also supported:
Requirements: Node.js >= 6.10, yarn
.
npm install -g serverless
.yarn
.brew install awscli
) and configure it with aws configure
. This operation will create ~/.aws/credentials
file with
default
profile. I recommend renaming it to something else so that your
default profile doesn't have full admin access.cp custom.yml.example custom.yml
. Edit custom.yml
file and provide your
desired configuration.serverless deploy
serverless s3deploy
The s3deploy
command attaches the event listener to an existing S3 bucket.
You need to run it only during the first deployment.
From now on any file you create/delete/rename on your S3 bucket will trigger
the AWS Lambda function and generate index.html
with the directory listing in
your current directory.
Directory listing, although statically generated by this project, has a dynamic nature and should not be cached by your CDN. To do this, go to your CloudFront distribution settings, select Behaviors tab and create a new behavior.
For Path Pattern type */index.html
and select custom Object Caching with
the value 0
for Min TTL, max TTL and Default TTL. Now CloudFront will bypass
the cache and will always fetch fresh index.html
file directly from your S3
bucket.
mocha --compilers js:babel-core/register test/test.js