CI/CD LabShortLink API · DevOps with AWS

From git push to production

CI/CD is the automation that carries a code change to real users: it builds it, tests it, deploys it and checks it works. Make a change, push it, and watch it happen.

1

Make a change

You are a developer on the ShortLink team. Pick what you are about to push.

Expected: everything passes and production gets the new version.

See the code change
src/routes/links.routes.js
+ router.delete('/bulk', async (req, res) => {
+ const deleted = await services.links.removeMany(req.body.codes)
+ res.json({ deleted })
+ })
Illustrative. This is the idea of the change, not a real file edit.
Advanced: break something in AWS

Real pipelines also fail for boring reasons: a missing permission, a stopped agent. Switch one on, then push.

2

Watch it travel to production

Each box is a stage in AWS CodePipeline. Nothing here is clicked by a person.

Continuous integrationbuild and test every change
Continuous deliveryship what was tested
The result

Source

GitHub → CodePipeline

Not started

Notices your push and takes a snapshot of the code.

  1. Your commit reaches GitHub
  2. GitHub tells AWS
  3. A copy of the code is saved
Repo
Amaan-Khan14/shortlink
Commit
—

Produces SourceArtifact

Build

AWS CodeBuild

Not started

Builds the code and runs the tests on a clean machine.

  1. Start a clean machine
  2. Fetch the code and tools
  3. Build and run the tests
  4. Package the result

Produces BuildArtifact.zip

Deploy

AWS CodeDeploy → EC2

Not started

Installs the tested package on the server, then checks it is healthy.

  1. Take the server out of the load balancer
  2. Install the new version
  3. Start it and check it works
  4. Put it back in the load balancer

Uses BuildArtifact.zip

Production

EC2 behind a load balancer

Serving users

What your users actually reach.

Running versiona1b2c3d

served error (503)

Waiting for traffic…

Server details
App process
running
Code on disk
a1b2c3d
Load balancer
healthy
Deploy agent
active
3

Where it runs in AWS

The same run, drawn as the AWS services involved. Click any box to see what it is.

How to read this

A box lights up while it is doing work.

A label travelling along a line is data moving between services.

Click any box to see what it is and where to find it in the AWS console.

Status

Nothing has been deployed yet