Skip to content

Guide 2

Backend CI/CD on EC2

Push to your fork and have the API tested, packaged and deployed to the private EC2 instance automatically with CodePipeline, CodeBuild and CodeDeploy.

Time
60–90 minutes
Level
Intermediate
Before you start
After guide 1 (chapters 1–9).
  1. 1Overview and prerequisitesHow a push to your fork becomes a running release on EC2, and what must already exist.10 min
  2. 2The deployment files in your forkRead appspec.yml, the buildspec and the four hook scripts so nothing in the pipeline is magic.15 min
  3. 3Prepare the EC2 serverInstall the CodeDeploy agent and confirm the server is ready to receive releases.15 min
  4. 4Create the CodeDeploy applicationA service role, an application and a deployment group that targets your server by its Name tag.20 min
  5. 5Connect AWS to your forkAuthorize the AWS Connector for GitHub on your fork so CodePipeline can read it.10 min
  6. 6Create the pipelineSource, Build and Deploy stages created with the CodePipeline wizard, triggered only by pushes that touch the API.25 min
  7. 7Permissions between the piecesWhy each IAM role needs its own policy, and the two policies you add so deployments can download and start.20 min
  8. 8Run the first releaseStart the pipeline, watch each stage, and prove the server now runs the CodeDeploy-managed version.20 min
  9. 9Ship a change, and break one on purposeMake a code change, push it, and watch it reach the server. Then see a failing test stop a bad release.25 min
  10. 10Rollbacks and day-to-day operationsUndo a bad release, retry a failed one, find the right log, and plan the next improvements.15 min
  11. 11TroubleshootingErrors you may meet while building and running the backend pipeline, what causes them and how to fix them.15 min