Core Concepts of AWS CodePipeline
To understand CodePipeline, you must be familiar with its foundational concepts, which define the structure and flow of your automated release process.
1. Pipeline
A pipeline is a workflow that defines how your software changes go from source control to your end-users. It is composed of a series of stages. Each pipeline has an Artifact Store, which is an S3 bucket used to store the artifacts (like source code and built applications) that are passed between stages.
2. Stage
A stage is a logical unit in your pipeline that groups one or more actions. A pipeline can have two or more stages.
-
Sequential Execution: Stages execute in order. A new stage only begins after the previous stage has been successfully completed.
-
Common Examples:
-
Source Stage: Fetches the latest code from a repository.
-
Build Stage: Compiles the code and runs unit tests.
-
Deploy Stage: Deploys the application to staging or production environments.
-
3. Action
An action is a task performed within a stage. Actions are the core building blocks of your pipeline.
-
Action Provider: This is the AWS service or third-party tool that performs the action. Examples include
AWS CodeCommit
,AWS CodeBuild
,AWS CodeDeploy
,Amazon S3
,AWS Lambda
, andJenkins
. -
Action Categories: Each action has a category that defines its purpose:
-
Source
: Required as the first action in a pipeline. It pulls code from a repository like AWS CodeCommit, GitHub, or an S3 bucket. -
Build
: Compiles code, runs tests, and creates build artifacts. -
Test
: Runs tests on the built code. -
Deploy
: Pushes the application to a service like AWS CodeDeploy or Amazon ECS. -
Approval
: Pauses the pipeline and waits for manual approval. -
Invoke
: Calls a custom AWS Lambda function.
-
-
Parallel Execution: Actions within the same stage can be configured to run sequentially or in parallel.
4. Artifacts
Artifacts are the files that are worked on by the pipeline actions.
-
Input Artifact: The set of files that an action works on (e.g., the source code used by a build action).
-
Output Artifact: The set of files produced by an action (e.g., the compiled application from a build action).
-
CodePipeline stores artifacts in the pipeline's artifact store (an S3 bucket) and automatically passes them from one stage to the next.
5. Transitions
A transition is the link between two stages. You can manually disable a transition to prevent a revision from flowing to the next stage. This is useful for temporarily holding a change before promoting it to a sensitive environment like production. Once you are ready, you can enable the transition to let the changes proceed.
How a Pipeline Works
A typical pipeline execution follows a clear, automated workflow:
-
Source Change: A developer pushes a code change to a source repository (e.g., a branch in a CodeCommit or GitHub repo).
-
Pipeline Trigger: CodePipeline detects the change and automatically starts a new execution (a "revision") through the pipeline.
-
Source Stage: The source action downloads the code and places it in the artifact S3 bucket.
-
Build Stage: The build action takes the source artifact as input, runs a build process using AWS CodeBuild, executes unit tests, and produces a new output artifact (e.g., a deployable ZIP file or Docker image).
-
Manual Approval (Optional): The pipeline can pause at an approval action, sending a notification via SNS. A user must then manually approve or reject the change in the console before the pipeline can continue.
-
Deploy Stage: The deploy action takes the build artifact as input and uses a service like AWS CodeDeploy or AWS CloudFormation to deploy the application to a test or production environment.
If any action fails, the pipeline stops at that point and reports a "Failed" status, preventing a bad change from progressing.
Key Features
-
Automation: Automates your entire release process, from source to production.
-
Integration: Seamlessly integrates with a wide range of AWS services (CodeCommit, CodeBuild, CodeDeploy, S3, ECS, Lambda) and third-party tools (GitHub, Jenkins).
-
Configuration: Easy to set up and configure a complete CI/CD pipeline using a visual interface in the AWS Management Console.
-
Flexibility: You can create simple or complex pipelines to match your specific workflow needs.
-
Manual Gates: Add manual approval actions to ensure changes are reviewed before being deployed to production.
-
Monitoring: Provides a clear visual representation of your pipeline's status and integrates with Amazon CloudWatch Events to trigger notifications or other automated actions based on pipeline events.