Setting up the Hugo website generator in CodePipeline

Last time, we used CDK to host a static website in AWS. Today we’re going to look at adding a static site generator to our pipeline so that we don’t have to create all of our pages by hand.

We’ve found the Hugo static site generator to be simple and effective, so we’ll use it for this example, but the steps should apply to any similar tool.

First, we’ll need a buildspec. This needs an install phase to set up the generator tool in the pipeline runner, and a build phase to execute it. It serves no practical purpose to upload the source files to S3, so we’ll only export the generated assets as artifacts. With Hugo, this will be the contents of the public/ directory.

[Read More]

Using CDK to set up a static website in AWS

Hosting a static website with S3 and Cloudfront in 2024

Setting up a static website in AWS is, in theory, very simple, and CDK makes deployment trivial. However, there are a few details that will frustrate efforts to get the job done.

We’ll be setting up a static website by hosting the source files in S3. A website served out of S3 can only be on HTTP, so we’ll need Cloudfront to handle secure connections with end users. We’ll also set up a pipeline for automated deployment of updates, and assign a domain name from Route53.

[Read More]