Lesson 2 of 2 DevOps and Continuous Delivery Foundations

Distinguishing Continuous Integration, Delivery and Deployment

Continuous integration, continuous delivery and continuous deployment are three related practices that are often confused. The difference between them decides where a pipeline needs a manual approval, how tests are organised and how much confidence the automation must provide. This lesson defines each practice precisely and shows how each one is built on AWS.

Learning outcomes

After completing this lesson, you will be able to:

  • Define continuous integration, continuous delivery and continuous deployment, and explain how they differ.
  • Describe the pipeline stages, gates and environments that each practice needs.
  • Choose the appropriate practice for a scenario based on its compliance and risk requirements.
  • Explain the pipeline design principles of building once, promoting the same artifact and failing fast.

Continuous Integration

Continuous integration (CI) is the practice of merging every developer's changes into a shared main branch frequently, at least daily, and verifying each merge with an automated build and automated tests. The goal is to detect integration problems while they are small. When developers work on long-lived branches for weeks, their changes diverge, and merging them becomes a large and error-prone task. CI keeps branches short-lived and makes the main branch the always-working version of the code.

A CI process has three essential elements. First, a version control system holds a single shared repository. Second, every push or pull request triggers an automated build that compiles the code and runs fast tests, typically unit tests and static analysis. Third, the team treats a broken build as the highest priority, because a broken main branch blocks everyone. On AWS, CI is usually implemented with AWS CodeBuild, started either by a webhook from the Git provider for pull requests or by an AWS CodePipeline source action for merges.

CI produces an artifact and a verdict. The artifact is the build output; the verdict is whether the change is safe to integrate. CI on its own does not deploy anything to a running environment.

Continuous Delivery

Continuous delivery extends CI so that every change that passes the automated tests is automatically prepared for release and deployed to one or more pre-production environments. The code is always in a releasable state, but the final release to production is a business decision that a person triggers, usually by approving a manual approval action. Continuous delivery is therefore the right choice when an organisation must keep human sign-off, for example to satisfy a change-management policy, a regulatory requirement or a release schedule agreed with customers.

Because the production deployment is still automated after approval, continuous delivery removes the risk of manual deployment steps. The approver decides when to release, not how. In AWS CodePipeline, this is modelled with a manual approval action placed in a stage before the production deployment stage. The approval can publish a notification to an Amazon Simple Notification Service (Amazon SNS) topic and include a URL to the test environment or the change review.

Continuous Deployment

Continuous deployment removes the manual approval. Every change that passes all automated stages is released to production without human intervention. This requires a high level of confidence in the automated tests and, equally important, in the deployment process: progressive traffic shifting, health checks and automatic rollback replace the human approval as the safety mechanism.

Continuous deployment is common for web services where the team owns the whole stack and can measure user impact quickly. On AWS, it is typically implemented with CodeDeploy canary or linear deployments for AWS Lambda and Amazon ECS, or with blue/green deployments for Amazon EC2, combined with CloudWatch alarms that stop and roll back the deployment when error rates or latency rise.

Comparing the Three Practices

The three practices form a progression: each includes everything in the previous one and adds more automation. The decisive difference between continuous delivery and continuous deployment is only the presence of a manual gate before production. The comparison below summarises the differences.

Continuous integration
Automated build and unit testsYes
Automatic deployment to test environmentsNot required
Production releaseNot part of CI
Main safety mechanismFast automated tests
Typical AWS building blocksCodeBuild, pull request webhooks
Choose when Developers need fast feedback on every change.
Continuous delivery
Automated build and unit testsYes
Automatic deployment to test environmentsYes
Production releaseAutomated, after a manual approval
Main safety mechanismTests plus human approval
Typical AWS building blocksCodePipeline with a manual approval action
Choose when A person or process must authorise each production release.
Continuous deployment
Automated build and unit testsYes
Automatic deployment to test environmentsYes
Production releaseFully automatic
Main safety mechanismTests plus progressive deployment and automatic rollback
Typical AWS building blocksCodePipeline, CodeDeploy canary or linear, CloudWatch alarms
Choose when Changes must reach users as fast as possible with automated safeguards.

The following diagram compares how far each practice automates a change.

Continuous integration, delivery and deployment compared across pipeline stages. All three build and unit test every change. Continuous delivery also deploys automatically to test environments and places a manual approval before production, after which the release itself is automated. Continuous deployment releases to production automatically, relying on progressive deployment and automatic rollback. The only difference between delivery and deployment is the manual gate.
Each practice adds automation to the one before it.
Sort into groups

CI, delivery or deployment?

Exam skills 1.1.5

Decide which practice each pipeline implements.

Log in to try this activity Interactive activities are free with an account.

Pipeline Design Principles

Whichever practice is used, well-designed pipelines follow several principles that the exam tests indirectly through scenario questions.

Build once, deploy many times

An artifact is built once, early in the pipeline, and the same artifact is promoted through every environment. Rebuilding for each environment risks deploying something different from what was tested, because a dependency could change between builds. Environment-specific values such as database endpoints are supplied at deployment time through parameters, AWS Systems Manager Parameter Store or AWS AppConfig, never baked into separate builds.

Fail fast

Cheap, fast checks run first. Linting, unit tests and template validation take seconds and catch most errors; slower integration and load tests run later and only for changes that passed the fast checks. This ordering gives developers feedback quickly and avoids spending time on changes that would fail anyway.

Keep environments consistent

Test, staging and production are created from the same IaC templates with different parameters. Differences between environments are a common cause of failures that appear only in production.

Make the pipeline the only path to production

If engineers can change production manually, the pipeline no longer records every change and drift appears. Permissions are arranged so that only the pipeline's roles can deploy to production accounts, and human access is read-only or temporary and audited.

Version everything

Application code, infrastructure templates, pipeline definitions, build specifications and configuration all live in version control. A pipeline can then be recreated, and the exact state of any past release can be reproduced.

Environments and Promotion

A pipeline usually promotes a change through a sequence of environments. A common sequence is development, test or integration, staging (also called pre-production) and production. Each environment adds confidence: integration tests in test, realistic load and acceptance tests in staging, and real traffic in production. In a multi-account strategy, each environment lives in its own AWS account, so a mistake in test cannot affect production resources and permissions can differ per environment. A central tooling account usually hosts the pipeline, which deploys into the environment accounts by assuming roles in them. Cross-account pipelines are covered in the AWS CodePipeline module.

Deployment waves

Production can itself be split into waves, such as one Region first and the remaining Regions later, or a small set of cells before the rest. Deploying in waves limits the impact of a faulty change to a fraction of users and is a common pattern in large AWS environments.

Worked example

Choosing the Practice for a Regulated Workload

A payment company must keep a record that a named release manager authorised each production change, but wants test environments to receive every change automatically. Its pipeline has Source, Build, Test and Production stages.

The requirement for a named approver rules out continuous deployment. Continuous delivery meets both needs: every change is built and deployed to the test environment automatically, and a manual approval action is placed at the start of the Production stage. CodePipeline records the identity of the IAM principal that approved the action and any comments, and AWS CloudTrail logs the PutApprovalResult API call, which provides the audit record. After approval, the production deployment itself is automated, so the release manager authorises the change without performing it.

Check yourself

A team already has automated tests and canary deployments with automatic rollback. Leadership wants every successful change to reach production without waiting for anyone. What should the team remove from its continuous delivery pipeline?

Show answer

The manual approval action before the production stage. Removing it turns continuous delivery into continuous deployment; the canary deployment and alarm-based rollback take over as the safety mechanism.

Exam Tips

Remember for the exam

  • Continuous delivery and continuous deployment differ only in the manual approval before production; if a scenario requires human sign-off, the answer is continuous delivery with a CodePipeline manual approval action.
  • Continuous deployment needs automated safeguards in place of the approval: progressive traffic shifting, health checks and CloudWatch alarm-based automatic rollback.
  • Build an artifact once and promote the same artifact through every environment; supply environment-specific values at deployment time.
  • Run fast checks such as linting and unit tests before slow integration and load tests (fail fast).