CodePipeline With CDK
Implement CDK Hugo Website.
This CDK stack creates a CodePipeline which is triggered by an CodeCommit.
In the example a
buildspec.yml for a gohuo static website deployment on a S3 bucket is included.
For a production website you would add an domain with R53 and a CloudFront CDN with https certificate.
All neccesary steps are included in a
Taskfile.yml, which is interpreted by task. See Task for installation details.
- The user pushed updates to the repo
- CodePipeline gets triggered by the EventRule
- Input Artifacts are stored on S3
- CodeBuils is triggered
- CodeBuild installes hugo and renders site
- CodeBuild copies site (in '/public' ) to website bucket
- install cdk
- install task
- clone this repository
- create a working directory outside this repository. We call it
- Edit copied
- Change line 8 to
- Change line 8 to
- `cd $workdir``
Examine deployed architecture
Look into the resources of the CloudFormation Stack.
You see the CodeCommit repository. Examine the Hugo Code.
You see the website bucket (Output
CodepipelineStack.websitebucketout from the Stack)
Open the website bucket in a browser. You see the deployed static website.
Play around, create new Hugo posts and push them to the CodeCommit repo. The website will be updated automatically.
- `task CodepipelineStack.websitebucketout
- Delete websitebucket (order buckets with "Date Created", you will the the two buckets)
- Delete gohugoartifactsbucket
Outputs: CodepipelineStack.websitebucketout = codepipelinestack-websitebucket976268b6-90738bunw6s6 CodepipelineStack.repocloneurl = https://git-codecommit.eu-central-1.amazonaws.com/v1/repos/myhugorepositoryname
Create hugo site
Choose a working directory and install hugo as described here: Quick Start | Hugo
hugo new site quickstart cd quickstart
Initialize git and add
git init git submodule add https://github.com/xaprb/story.git themes/story git remote add origin https://git-codecommit.eu-central-1.amazonaws.com/v1/repos/myhugorepositoryname
buildspec.yml from the
assets/buildspec.yml to the
Add theme and content
echo 'theme = "story"' >> config.toml hugo new posts/my-first-post.md echo public >>.gitignore
git add . git commit -m "Quickstart initial" git push --set-upstream origin master
For this to work you have to have a valid AWS profile running and the credential helper installed: Setup Steps for HTTPS Connections to AWS CodeCommit Repositories on Linux, macOS, or Unix with the AWS CLI Credential Helper - AWS CodeCommit
Goto the AWS Console to CodeBuild and monitor the deployment pipeline.
Add Content and push
With each push you pipeline will be executed and the generated files will be copied to the websitebucket.
git add . git commit -m "Some meaningfull message" git push
Websitebucket is not deleted! Because its rendered with