A simple static website to explore how an AWS CodePipeline can be used to automatically deploy updates when commits are made to a GitHub repo. The intent was to produce a generic piece of infrastructure code that could be added to a static website repo without a lot of effort.
To use this code, run infra/bootstrap.sh
once and the pipeline should be configured and ready to go. It will perform the following steps:
- Launch the bootstrap.yml CloudFormation template:
- Create a KMS key with alias
alias/${ProjectName}-${BranchName}-kmskey
to encrypt the code artifacts stored in an S3 bucket - Create S3 bucket
${ProjectName}-${BranchName}-code-artifact
required by CodePipeline to store the code artifacts produced and consumed throughout the pipepline. - Create an IAM role for the codepipeline to assume when running
- Create an IAM role for the webite pipeline to assume when deploying the artifacts to S3
- Create a CodePipeline to build the infrastructure needed:
Source
stage - pull the code from GitHub repo and store in the artifact S3 bucketDeploy-Bucket
stage - use CloudFormation templatebucket.yml
to create the S3 static website bucket, configured to serve the HTML siteDeploy-Pipeline
stage - use CloudFormation templatepipeline.yml
to create the pipeline for updating website bucket with the latest code
- Create a KMS key with alias
- The bulk of this logic came from James Turner's From GitHub to Continuous Deployment in 5 Minutes. Per his article, I also followed the steps in Connecting Github to AWS Codepipeline which produces an AWS GitHub (v2) connector credentials-arn used in bootstrap.sh.
- The index page and background I based on Isabel Castillo's Our Site Has Moved HTML Responsive Template
- The 404 page I based on the Bootstrap snippet Simple & Clean 404 Error Page Design