Understanding Pipelines in AWS CodePipeline
AWS CodePipeline models a release process as a sequence of stages that pass artifacts from one to the next. This lesson explains the building blocks of a pipeline, how executions move through stages, the difference between pipeline types V1 and V2, and the execution modes that decide what happens when several changes arrive close together.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the structure of a pipeline: stages, actions, action categories, artifacts and run order.
- Explain how CodePipeline stores and encrypts artifacts and which role performs each action.
- Distinguish between pipeline types V1 and V2 and between the SUPERSEDED, QUEUED and PARALLEL execution modes.
- Explain how transitions, retries and stage locks affect pipeline executions.
Pipeline Building Blocks
A pipeline is a workflow definition. It consists of an ordered list of stages, and each stage contains one or more actions. The first stage must contain only source actions, and every pipeline needs at least two stages. A pipeline execution is one run of the pipeline for a particular set of source revisions. The definition is a JSON or YAML structure, which is normally managed in CloudFormation or the AWS CDK so that the pipeline itself is version controlled.
- Stage
- A logical unit such as Build, Test or Production. A stage processes one execution at a time and passes when all its actions succeed.
- Action
- A task performed on artifacts, such as running a build or deploying a stack. Each action has a category, an owner (AWS, third party or custom), a provider and a configuration.
- Artifact
- A named set of files that an action produces as output and later actions consume as input, such as SourceOutput or BuildOutput.
- Run order
- An integer on each action. Actions in a stage with the same run order run in parallel; higher numbers run after lower ones finish.
- Transition
- The link between two stages. A transition can be disabled to stop executions from entering the next stage.
Action categories
Each action belongs to one of the following categories, which determines where it may be placed and how it behaves.
| Category | Examples of providers | Purpose |
|---|---|---|
| Source | CodeConnections (GitHub, GitLab, Bitbucket), Amazon S3, Amazon ECR | Capture a revision and produce the first artifact |
| Build | AWS CodeBuild, Jenkins | Compile and package |
| Test | AWS CodeBuild, third-party test services | Run tests and report pass or fail |
| Deploy | CloudFormation, CodeDeploy, Amazon ECS, Elastic Beanstalk, Amazon S3, AWS AppConfig, Service Catalog | Release to an environment |
| Approval | Manual approval | Wait for a person to approve or reject |
| Invoke | AWS Lambda, AWS Step Functions, Amazon Inspector scan | Call a service to perform custom work or checks |
| Compute | Commands | Run shell commands on CodeBuild-managed compute without a separate project |
The Commands action runs a list of shell commands directly in the pipeline on CodeBuild compute. It suits small steps, such as running a script or calling the AWS CLI, that do not justify a separate CodeBuild project; complex builds still use a CodeBuild action with a buildspec.
The following diagram shows stages, actions, run order and artifacts in one pipeline.

Artifacts, Encryption and Roles
CodePipeline passes artifacts between actions through an artifact store, an Amazon S3 bucket in the same Region as the pipeline. When a pipeline is created in the console, CodePipeline creates a default bucket per Region; in IaC, you specify the bucket. Each artifact is stored as a ZIP object. By default, artifacts are encrypted with the AWS managed key for Amazon S3. A pipeline can instead specify a customer managed AWS KMS key, which is required for cross-account pipelines because an AWS managed key cannot be used by another account.
CodePipeline uses a pipeline service role to call other services, such as starting a CodeBuild build, calling CodeDeploy or reading the artifact bucket. An action can also specify its own roleArn, which CodePipeline assumes for that action only. This is the mechanism for cross-account deployment, described in a later lesson. Some actions use further roles: a CloudFormation deploy action passes a separate CloudFormation service role that CloudFormation uses to create resources, so the pipeline role does not need permission to create every resource itself.
Which role failed?
When an error says that CodePipeline is not authorised to perform an action, check the pipeline service role or the action role. When CloudFormation reports that it cannot create a resource, check the CloudFormation service role passed by the action, which also requires iam:PassRole permission in the pipeline or action role.
How Executions Move Through Stages
When a source change is detected, CodePipeline starts an execution, runs the source stage and then moves the execution into each following stage in turn. A stage succeeds when all of its actions succeed. If an action fails, the stage fails and the execution stops; later stages do not run. A failed stage can be retried, either retrying only the failed actions or all actions, without restarting the pipeline, which is useful when a failure was caused by a transient problem such as a throttled API.
A stage holds a lock while an execution is in it, so only one execution occupies a stage at a time. What happens to a second execution that reaches an occupied stage depends on the execution mode.
Disabling transitions
Disabling the transition into a stage lets executions complete earlier stages but prevents them from entering that stage until the transition is enabled again. Teams use this to freeze production deployments during an incident or a change freeze while still allowing builds and tests to run.
How executions move
Pipeline Types and Execution Modes
CodePipeline has two pipeline types. V1 is the original type. V2 adds pipeline-level variables, triggers with branch, tag, file path and pull request filters, the QUEUED and PARALLEL execution modes, stage conditions, automatic rollback on stage failure and source revision overrides. V2 pipelines are charged per minute of action execution, while V1 pipelines are charged per active pipeline per month. New pipelines should use V2.
V2 pipelines support three execution modes, explained below and then compared.
SUPERSEDED
This is the default and the only mode for V1. If a newer execution reaches a stage that is occupied, it waits; if an even newer execution arrives, the waiting one is superseded and abandoned. Only the most recent change is deployed, which is efficient for services where only the latest code matters, but it means intermediate commits might never be deployed on their own.
QUEUED
Executions are processed one at a time in the order they started. Each waits for the previous execution to finish the stage, and none are superseded. This mode suits pipelines in which every change must be deployed in sequence, for example database migrations, where skipping a version would break later ones.
PARALLEL
Executions run independently of each other and do not wait for stage locks. This suits pipelines in which each execution works on its own target, such as building pull requests or creating separate feature environments. It is not suitable when executions deploy to the same environment, because they could overwrite each other.
The following diagram shows what each mode does with three executions started close together.

Choose the execution mode
Choosing an Execution Mode
A data team's pipeline applies schema migration scripts to a database and then deploys an application. Developers sometimes merge several commits within minutes. After one burst of merges, migration 0042 was never applied, and the application failed because migration 0043 assumed it existed.
The pipeline uses SUPERSEDED mode, so the execution carrying 0042 was replaced by the newer execution while waiting. Changing the pipeline to type V2 with the QUEUED execution mode ensures that every execution passes through every stage in order, so each migration runs. PARALLEL mode would be wrong, because concurrent migrations against the same database could conflict.
During an incident, a team wants builds and tests to keep running on new commits but no changes to reach production until the incident is resolved. What is the simplest CodePipeline control?
Show answer
Disable the transition into the production stage. Executions complete the earlier stages and wait; enabling the transition later lets the newest one proceed.
Exam Tips
Remember for the exam
- Actions with the same runOrder in a stage run in parallel; use different runOrder values for sequential steps within a stage.
- Cross-account pipelines need a customer managed KMS key for the artifact bucket; the AWS managed S3 key cannot be used by other accounts.
- Use V2 with QUEUED mode when every change must be deployed in order, PARALLEL when executions are independent, and the default SUPERSEDED when only the latest change matters.
- Disable a stage transition to stop changes reaching an environment without stopping earlier stages.
- A failed stage can be retried (failed actions or all actions) without starting a new execution.