Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

AWS CodePipeline

AWS CodePipeline: continuous delivery service concepts, pipeline structure, key components, example pipeline JSON and execution traces, security and exam-focused notes.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Two or three sentences: AWS CodePipeline is an AWS service used by engineers to automate the steps of building, testing and deploying applications (continuous delivery). You use it to make releases repeatable, fast and auditable by connecting source, build and deploy stages with approvals and artifact storage.

Key ideas

Start from first principles and plain definitions before using terms.

  • Continuous delivery: the practice of keeping code in a deployable state and automatically moving changes through a sequence of steps (build, test, deploy) so production releases are frequent and low-risk.

  • Pipeline: a declarative object in CodePipeline that defines an ordered sequence of stages. A pipeline is the top-level resource you create and manage. It has a name, a service role, an artifact store, and an ordered list of stages.

  • Stage: a named phase inside a pipeline. Examples: Source, Build, Test, Deploy, Approval. Stages are executed in order from first to last. A stage contains one or more actions.

  • Action: a unit of work inside a stage. Each action has a type (Source, Build, Test, Deploy, Approval, Invoke), a provider (e.g., AWS CodeCommit, GitHub, AWS CodeBuild, AWS CodeDeploy, CloudFormation), a configuration, and input/output artifacts. Within a stage, actions with the same runOrder value run in parallel; use runOrder to sequence actions within a stage (lower numbers run first; higher numbers run after).

  • Artifact: an immutable bundle of files produced by one action and consumed by another. Stored in an artifact store (an Amazon S3 bucket). Each artifact has a name and a location (S3 object key and version). Artifacts let actions pass build outputs, deployment packages, or test reports to later steps.

  • Artifact store: an Amazon S3 bucket where pipeline artifacts are stored. Actions do not specify their own stores. For cross-region pipelines, define additional artifactStores at the pipeline level for each region. Ensure the primary bucket region matches the pipeline region. Optionally specify a KMS encryption key for artifact encryption.

  • Service role (pipeline role): an IAM role assumed by CodePipeline (principal codepipeline.amazonaws.com) that permits actions such as reading/writing artifacts in S3 and starting CodeBuild builds or invoking deployments. Each action provider may also need its own IAM role (for example, CodeBuild has a build role that CodeBuild assumes).

  • Execution: a single run of a pipeline from the first stage through to the last. Each execution has a unique execution ID and a status (InProgress, Succeeded, Failed, Superseded).

  • Transition: movement of an artifact from one stage to the next. Transitions can be enabled or disabled for manual control.

  • Webhook: an HTTP callback from an external source (for example, GitHub) that triggers a pipeline execution when a commit or pull request event occurs.

  • Revision: a specific source version or commit that triggered the pipeline run. The revision ID is used for traceability.

Assumptions behind the model: artifacts are immutable for an execution; stages run in order; IAM role trust and permissions must be correct for the pipeline and each service used. Diagram to draw for an exam: draw a horizontal flow with boxes labeled Source -> Build -> Test -> Deploy. Label arrows with artifact names (e.g., source.zip). Draw above each box the provider (e.g., CodeCommit, CodeBuild, CodeDeploy). Add the S3 bucket below as artifact store and an IAM role arrow from CodePipeline to S3 and to CodeBuild/CodeDeploy showing role assumption.

Formulas

For a programming / configuration topic, list syntax to remember:

  • AWS CLI create pipeline: aws codepipeline create-pipeline --cli-input-json file://pipeline.json
  • Minimum pipeline JSON structure (syntax to remember): { "pipeline": { "name": "MyPipeline", "roleArn": "arn:aws:iam::123456789012:role/MyCodePipelineRole", "artifactStore": {"type":"S3","location":"my-artifact-bucket"}, "stages": [ {"name":"Source","actions":[ ... ]}, ... ], "version": 1 } }
  • Example action block fields to remember: name, actionTypeId (category, owner, provider, version), runOrder, configuration, inputArtifacts, outputArtifacts, roleArn (optional).
  • Start a pipeline execution (CLI): aws codepipeline start-pipeline-execution --name MyPipeline
  • Get pipeline execution history (CLI): aws codepipeline list-pipeline-executions --pipeline-name MyPipeline

When these syntaxes apply: use them when creating, invoking, or debugging pipelines from scripts or CI scripts.

Worked examples

Example 1 — Step-by-step execution trace (Source -> Build -> Deploy)

Given: A pipeline named "AppPipeline" with stages Source (CodeCommit), Build (CodeBuild) and Deploy (CodeDeploy). Artifact store: S3 bucket app-pipeline-artifacts.

Steps and trace (numbered):

  1. Developer pushes commit to CodeCommit repository app-repo. Revision ID r1 created.
  2. CodePipeline detects the revision (via polling or webhook) and creates an execution e-001 with source revision r1.
  3. Source action checks out files and creates artifact SourceArtifact with S3 key app-pipeline-artifacts/e-001/source.zip. The artifact is immutable for e-001.
  4. Build action (CodeBuild) is started by CodePipeline using the pipeline role to call codebuild:StartBuild or via CodeBuild integration. Build reads SourceArtifact from S3 and produces BuildArtifact at app-pipeline-artifacts/e-001/build.zip.
  5. If build succeeds, pipeline moves to Deploy stage. CodeDeploy action reads BuildArtifact and creates a deployment with application MyApp and deployment group MyDG. CodeDeploy returns status. If deployment succeeds, pipeline execution e-001 completes with status Succeeded.

Final: For the exam, list each artifact location, each role used (pipeline role and CodeBuild role), and the final execution ID and status.

Example 2 — Minimal pipeline JSON (exam-style answer, annotated)

Write a minimal pipeline JSON to connect a CodeCommit source, CodeBuild build project, and a CodeDeploy deploy action. Include required top-level fields.

Model answer (explain what to draw or list):

  • Show JSON with pipeline.name, roleArn, artifactStore (S3 location), and stages array. Under Source stage put an action with actionTypeId category Source, owner AWS, provider CodeCommit, and configuration RepositoryName and BranchName. Under Build stage use CodeBuild provider and reference ProjectName in configuration. Under Deploy stage use CodeDeploy provider and configuration keys ApplicationName and DeploymentGroupName.

Notes: this JSON will be passed to aws codepipeline create-pipeline --cli-input-json file://pipeline.json.

Example 3 — Manual approval action use-case (short answer model)

Question: Where to place a manual approval to gate deployments to production? Answer: Insert an Approval stage between Test and Deploy stages. The Approval action pauses the stage and waits until an approver approves or rejects via Console, CLI or SDK; the pipeline execution remains InProgress while waiting. Include who can approve by IAM (users with codepipeline:PutApprovalResult). For an exam, mention that waiting does not incur extra CodePipeline charges beyond standard pricing, but downstream services may still incur costs; executions wait until approved/rejected or are manually stopped.

Common mistakes

  • Not enabling S3 bucket versioning for artifact buckets — CodePipeline requires versioning on artifact buckets; pipelines and actions may fail without it.
  • Wrong actionTypeId values or wrong configuration keys in the pipeline JSON — CodePipeline rejects the pipeline or actions fail at runtime.
  • Not granting webhook permissions or using invalid webhook secrets when integrating GitHub — pipeline won’t trigger on push.
  • Assuming pipeline automatically cleans up old artifacts — S3 costs still apply; set lifecycle rules.

For your exam

Kinds of questions and full-marks answers include:

  • Definitions: define pipeline, stage, action, artifact, artifact store, service role, execution. Full marks: concise definitions plus one example each.
  • Short notes: write about Source integration (CodeCommit/GitHub), Build integration (CodeBuild), Deploy integrations (CodeDeploy/CloudFormation). Full marks: list configuration fields and a short example of each integration.
  • Diagram: draw pipeline flow (Source -> Build -> Test -> Approve -> Deploy), label artifact S3 bucket and pipeline IAM role arrows. Full marks: show artifact names on arrows and list action providers.
  • Configuration/JSON: write minimal pipeline JSON and explain each field. Full marks: valid JSON structure with pipeline top-level, roleArn, artifactStore, stages array and one complete action block.
  • Debugging/permissions: explain why a pipeline fails to start builds (missing IAM permissions) and show minimum policies needed. Full marks: identify the correct principal (codepipeline.amazonaws.com) and list at least S3 + CodeBuild permissions.
  • Short program/script: give AWS CLI or SDK sequence to create artifact bucket, create role, and create pipeline. Full marks: correct order and correct CLI command names.

Do not attempt to memorize every IAM policy statement for exams; instead show the principal and the types of actions that must be allowed (S3, CodeBuild, CodeDeploy, etc.) and an example policy snippet.

Quick check

  1. What is an artifact in CodePipeline?
  2. Name two providers you can use in a CodePipeline stage.
  3. Which AWS service stores CodePipeline artifacts by default?

Answers: An artifact is an immutable bundle of files produced by one action and consumed by another; examples of providers: CodeCommit and CodeBuild (also GitHub, CodeDeploy, CloudFormation); artifacts are stored in Amazon S3 by default.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?