Create S3 redirects with the AWS CLI

To create a redirect on S3, use the AWS CLI to upload an empty file with the x-amz-website-redirect-location metadata key set.

First, create an empty file:

touch empty

Then upload that file to the origin of the redirect, and point it to the target with the --website-redirect flag:

aws s3 cp empty \
    s3://jeffkreeftmeijer.com/.emacs.d/index.html \
    --website-redirect=https://jeffkreeftmeijer.com/emacs-configuration \
    --acl public-read