This script exploits the error document functionality of S3 static websites to create an Apache-style directory index of your bucket.
-
Copy
list.html
into the S3 bucket where you want to serve a directory listing.- Edit
s3Params
to reflect the bucket name and appropriate S3 endpoint. (reference) - Edit
ignoreList
to exclude any files from the directory index.
- Edit
-
Grant
Everyone
List permissions. -
Enable Static Website Hosting.
- Set the Index Document to
index.html
. - Set the Error Document to
list.html
. - Note the endpoint.
- Set the Index Document to
-
Add the following CORS policy:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedMethod>GET</AllowedMethod>
<AllowedOrigin>http://{{ endpoint }}</AllowedOrigin>
</CORSRule>
</CORSConfiguration>
See LICENSE
Idea based on https://github.com/rgrp/s3-bucket-listing (which was itself based on http://aws.amazon.com/code/Amazon-S3/1713). Styles taken from the default vsftpd directory index template.