AWS Lambda function for updating a Hugo blog hosted in S3/CloudFront
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
main.go

README.md

Huh?

This Go code is meant to be run in AWS Lambda and is what I use to update my blog, the source of which is stored on GitHub and hosted in S3 and CloudFront.

How

  1. Download the 64-bit Linux version of hugo from here: https://github.com/gohugoio/hugo/releases
  2. Put the hugo binary in the same directory as this repository
  3. Create the AWS Lambda bundle: GOOS=linux go build main.go && zip main.zip main hugo
  4. This will create main.zip which is your Lambda function.

When you create you Lambda function, pick a decent function timeout and memory usage. I use a 1 Minute timeout and 512MB function memory and it works for me. YYMV.

Environment variables to set

Env Var Description example
GIT_REPO The URL for the Git repository that hosts your Hugo blog https://github.com/wnka/pdp80-blog.git
S3_BUCKET The S3 bucket that hosts your blog pdp80.com
S3_REGION The AWS region your S3 bucket lives in us-east-1
CLOUDFRONT_DISTRO (Optional) The CloudFront that should invalidated on update E3W5ET0Z9WW0IT