This is the CloudFormation template for my personal website. This repository uses SAM, a handy wrapper around CloudFormation. The lambda regenerates the static website assets using Hugo.
For an initial setup, run:
$ pip3 install --user --upgrade awscli aws-sam-cli
If the stack does not exist yet, create the ECR (docker image) repository:
$ aws ecr create-repository --repository-name webzone --region us-east-1
and put the repositoryUri
printed above in $repository_uri
at the top of
update.sh
. Additionally, set
$ export WEBHOOK_SECRET=SomeSecretValue
To avoid having to do this every time, it's helpful to write SomeSecretValue
to ~/.webhook-secret
and then add the following to your .bashrc
:
read -r WEBHOOK_SECRET <~/.webhook-secret
export WEBHOOK_SECRET
To update, once you've done all that:
$ ./update.sh
Additionally, the first time you run this, you'll need to:
./update.sh
as the webhook URL. Choose "only push
". Add the secret
$WEBHOOK_SECRET
.To locally test the lambda, you can use ./test.sh
... almost. Something is
broken about connecting to CloudFront but I don't care enough to debug. It
works well enough for checking syntax errors, at least.
To create a redirect:
$ aws s3api put-object --website-redirect-location 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' --bucket austinjadams-com-website --key /redirect-from-here