Building CI/CD Pipelines with AWS CodePipeline - Automation from Source to Deployment
Automate everything from detecting source changes through build / test / deploy. This article introduces the design of V2 trigger filters, manual approval actions, and cross-account deployments.
CodePipeline Overview
CodePipeline is a CI/CD service that automates everything from source code changes to deployment. The source stage detects changes in GitHub or CodeCommit, CodeBuild runs tests and builds in the build stage, and CodeDeploy or CloudFormation performs the deployment in the deploy stage.
Pipeline Design
With the V2 pipeline type, trigger filters let you start a pipeline only on changes to specific branches or file paths. You place a manual approval action before the deploy stage and send an email to approvers through an SNS notification. For cross-account deployments, you grant access to the production account's role in the bucket policy of the pipeline's artifact S3 bucket and in the KMS key policy, and the deploy action performs AssumeRole on the production account's role.
Deployment Strategies and Rollback
In the CodePipeline deploy stage, you can perform blue/green deployments and canary deployments in conjunction with CodeDeploy. In an ECS blue/green deployment, a new task set is launched and verified with test traffic, and if there are no problems, production traffic is switched over. After the switch, the old task set is kept for a certain period, so if a problem occurs, you can go back to the old task set. In a Lambda canary deployment, 10% of traffic is sent to the new version and the error rate is monitored with CloudWatch Alarms, and if a threshold is exceeded, it rolls back automatically. With the CloudFormation deploy action, you can set up a flow that separates creating and executing a change set, so that the changes are checked through manual approval before execution.
Pipeline Monitoring and Failure Response
Because the pipeline's execution state is published as EventBridge events, you can notify Slack through SNS on failure or run automatic retries with Lambda. You visualize the pipeline's execution time, success rate, and the duration of each stage with CloudWatch metrics, and track rising trends in build time and changes in deployment frequency. Dependency errors in the build stage and insufficient permissions in the deploy stage can cause failures, so you regularly review the dependency cache settings in buildspec.yml and the scope of the IAM role's permissions. In pipeline V2, you can define pipeline-level variables, which lets you parameterize environment names and target deployment regions and reuse the same pipeline definition across multiple environments.
CodePipeline Pricing
The CodePipeline V2 type is billed on a pay-as-you-go basis according to the number of action executions, with the first 100 executions per month free and about $0.002 per execution beyond that (as of August 2026). The V1 type has a fixed fee of about $1.00 per pipeline per month. You choose the pipeline type from V1 and V2, and V2 has, in addition to the V1 structure, parameters for release safety and trigger configuration. CodeBuild build charges (about $0.005 per minute for build.general1.small) and CodeDeploy charges (EC2 deployments are free) are incurred separately. Which of V1 and V2 is cheaper changes depending on the frequency of executions.
Configuring Stages and Actions
CodePipeline is configured by arranging processes such as source retrieval / build / test / deploy in order as stages. In each stage, you place actions that perform the actual processing. For example, the source stage retrieves repository changes, the build stage runs compilation and tests, and the deploy stage releases to production. Before a production deployment, you can also insert a human approval step and proceed after a final check. You can run multiple actions in parallel. By explicitly configuring the processes as stages, the release flow becomes easier to understand and easier to manage.
Integration with Other Services and Extension
CodePipeline works in conjunction with a variety of services. It delegates builds and tests to a build service and deployments to various deployment methods, and incorporates them as actions in the pipeline. You can also incorporate infrastructure provisioning as an IaC deployment. If you incorporate third-party tools or functions that perform custom processing as actions, you can build a pipeline that fits your organization's own development flow. Combined with a mechanism that detects changes to the repository and starts the pipeline automatically, you can run everything from commit to release automatically.
Summary
CodePipeline is a CI/CD orchestration service that automates everything from source code changes to deployment. You can set the start conditions with V2-type trigger filters, perform blue/green and canary deployments in conjunction with CodeDeploy, and automate pipeline monitoring and failure notifications in conjunction with EventBridge. By combining manual approval actions, you can insert a human check in the middle of automated deployments.
References (Official AWS Resources)
The primary sources for this page are the official AWS website and documentation. Check the official pages below for the latest specifications and pricing.
- AWS CodePipeline official page
- AWS CodeBuild official page
- AWS CodeDeploy official page
- AWS Documentation (official)
If this page and the official documentation disagree, treat the official documentation as authoritative.