Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

aws-cd-pipeline

A demo project of a CD pipeline built with AWS Code-suite tools for a talk I gave. Slides are available on Speakerdeck.

Start

To get up and running, clone the repo and create the pipeline in your AWS account:

REGION=eu-central-1
SERVICE_NAME=cd-demo
STACK_NAME=cd-demo-pipeline

aws cloudformation create-stack \
--region ${REGION} \
--stack-name ${STACK_NAME} \
--template-body file://infrastructure/pipeline.yml \
--parameters ParameterKey=Service,ParameterValue=${SERVICE_NAME} \
--tags Key=Service,Value=${SERVICE_NAME} \
--capabilities CAPABILITY_IAM

Wait until the stack is created. Then, get the git URL of the CodeCommit repo:

aws cloudformation describe-stacks \
--region ${REGION} \
--stack-name ${STACK_NAME} \
--query 'Stacks[0].Outputs'

Add it as a new remote:

# replace the URL
git remote add aws ssh://git-codecommit.eu-central-1.amazonaws.com/v1/repos/cd-demo

And finally push to that repository git push aws master. That should trigger the first run of the pipeline.

If you want to know a little more about what's going on, check out this older, but similar repo I have.

Tips, tricks, opinions, dos and donts

Here's an assorted and opinionated list of things to consider when creating a CD pipeline. Some you can apply right away, some are more advanced which you can build in later iterations.

  • Always make the pipeline update itself as the second stage. This is very easy to do, just copy the second stage in this example pipeline. Don't forget to set the RestartExecutionOnUpdate to true.
  • Always pass all the template parameters back via the ParameterOverrides. This is 1) easy to forget and 2) error-prone as you need to write a JSON string with CloudFormation string interpolation syntax inside a YAML 🤷‍♂️.
  • Automate everything.
  • Consider measuring the following metrics:
    • Execution duration of the whole pipeline
    • Execution duration of the build process (CodeBuild)
    • Execution fail rate
  • Prefer GitHub instead of CodeCommit because it's region agnostic and slightly faster to trigger the pipeline execution.
  • Be careful if using SAM for deployments (the AutoPublishAlias and DeploymentPreference combo). It can work well, but it's too much magic.
  • Be absolutely sure the CloudWatch alarm you use to monitor a successful/failed deployment triggers correctly.
  • When deploying across multiple regions, start in a low traffic one.
  • Don't use a gradual rollout policy for non-production stages.
  • Have separate, isolated deployment stages and resources as much as possible (e.g. dev, alpha, beta, qa, prod, ...).
  • Have separate, isolated AWS accounts per deployment stage.
  • CodeBuild tips:
    • Run verbose commands in quite mode
    • Print useful progress messages
    • Use a cache to speed up your build
    • Put "complex" multiline commands in a .sh file.
    • Update the aws-cli if you need support for newish services
    • Use CodeBuild local for debugging

Documentation links

The official documentation is pretty great, but hard to navigate. Here's a list of starting points that will hopefully help you to find what you're looking for.

Other helpful presentations

About

A demo of a CD pipeline built with AWS Code-suite of tools

Resources

License

Releases

No releases published

Packages

No packages published

Languages