TOUCH-SAFE SORT HEADER UPDATE (v96) - The generated directory listing column headers "Name", "Last modified", and "Size" are now much larger touch targets. - Deploy lambda-edge-directory-browser/index.mjs to Lambda@Edge and publish a new version to make the public directory pages show the larger headers. START HERE — 8k.art S3 + CloudFront Directory Indexer ============================================================ This is the amnesia-safe deployment checklist. GOAL ---- Make https://8k.art/beta/ browseable like an Apache directory. Let CloudFront cache directory pages and .directory-index.json for 365 days. When S3 changes, the updater Lambda rebuilds the index and invalidates CloudFront. FILES AND WHERE THEY GO ----------------------- 1. s3-directory-index-updater/index.mjs Goes to: normal AWS Lambda triggered by S3 ObjectCreated/ObjectRemoved events. Purpose: rebuild .directory-index.json and invalidate CloudFront. 2. s3-directory-index-updater/package.json Goes with the updater Lambda deployment package. Purpose: dependencies @aws-sdk/client-s3 and @aws-sdk/client-cloudfront. 3. lambda-edge-directory-browser/index.mjs Goes to: Lambda@Edge in us-east-1, CloudFront Origin request association. Purpose: render public folder pages like https://8k.art/beta/. 4. cloudfront-function-headers/allow-all-cors-and-inline-text.js Goes to: CloudFront Function, usually Viewer response. Purpose: CORS and inline text/source display headers. 5. Documentation/source files in this package Go to: s3://www.8k.art/beta/s3-cloudfront-indexer/ Purpose: public documentation and source package. REQUIRED UPDATER LAMBDA ENVIRONMENT VARIABLE ------------------------------------------- CLOUDFRONT_DISTRIBUTION_ID=YOUR_8K_ART_DISTRIBUTION_ID Recommended explicit values: ENABLE_CLOUDFRONT_INVALIDATION=true DIRECTORY_INDEX_CACHE_CONTROL=public, max-age=31536000, s-maxage=31536000, immutable UPDATE_BUCKET_ROOT_INDEX=false REQUIRED IAM PERMISSION ----------------------- The updater Lambda role needs cloudfront:CreateInvalidation. Use policies/s3-directory-index-updater-policy-example.json and replace YOUR_BUCKET_NAME with www.8k.art. DEPLOYMENT ORDER ---------------- 1. Upload this package to s3://www.8k.art/beta/s3-cloudfront-indexer/ for public docs. 2. Deploy s3-directory-index-updater/index.mjs to the S3 event updater Lambda. 3. Set CLOUDFRONT_DISTRIBUTION_ID on that updater Lambda. 4. Verify updater Lambda has S3 trigger for ObjectCreated and ObjectRemoved. 5. Deploy lambda-edge-directory-browser/index.mjs to Lambda@Edge in us-east-1. 6. Publish a numbered Lambda@Edge version. 7. Attach that numbered version to CloudFront as Origin request for the beta behavior. 8. Deploy cloudfront-function-headers/allow-all-cors-and-inline-text.js as CloudFront Function if needed. 9. Test upload, overwrite, delete in s3://www.8k.art/beta/. 10. Confirm https://8k.art/beta/ updates after invalidation. DO NOT DO THESE THINGS ---------------------- - Do not delete the CloudFront distribution. - Do not delete old Lambda versions before testing. - Do not attach $LATEST to Lambda@Edge. Use a numbered version. - Do not remove the updater Lambda S3 event trigger. - Do not depend on short cache TTLs. The intended model is 365-day cache plus invalidation. TEST ---- Upload: beta/test-cache-invalidation.txt Refresh: https://8k.art/beta/ Overwrite the file. Refresh the file URL through CloudFront. Delete the file. Refresh https://8k.art/beta/ SUCCESS ------- If folder listings and changed files update after S3 changes, while unchanged content can cache for a year, the system is working.