Day 53 - AWS CodePipeline

Day 53 - AWS CodePipeline

What is AWS CodePipeline?

AWS CodePipeline is a fully managed continuous delivery service that helps you automate your release pipeline. It allows users to build, test and deploy code into a test or production environment using either the AWS CLI or a clean UI configuration process within the Amazon Console.

You can easily integrate AWS CodePipeline with third-party services such as GitHub or with your own custom plugin.

Features of AWS CodePipeline

Several features of AWS CodePipeline is: -

  1. Parallel Execution: You can use CodePipeline to model your build, test, and deployment actions to run in parallel in order to increase your workflow speeds.

  2. AWS integrations: AWS CodePipeline can pull source code for your pipeline directly from AWS CodeCommit, GitHub, Amazon ECR, or Amazon S3. It can run builds and unit tests in AWS CodeBuild. CodePipeline can deploy your changes using AWS CodeDeploy, AWS Elastic Beanstalk, Amazon Elastic Container Service (Amazon ECS), or AWS Fargate. You can also trigger custom functions defined by code at any stage of your pipeline using CodePipeline's integration with AWS Lambda. It also lets you configure a pipeline that ties these services together along with third-party developer tools and custom systems.

  3. Pre-built plugins: AWS CodePipeline allows you to integrate third-party developer tools, like GitHub or Jenkins, into any stage of your release process with one click. You can use third-party tools for source control, build, test, or deployment.

  4. Custom plugins: AWS CodePipeline allows you to integrate your own custom systems. You can register a custom action that allows you to hook your servers into your pipeline by integrating the CodePipeline open source agent with your servers. You can also use the CodePipeline Jenkins plugin to easily register your existing build servers as a custom action.

  5. Declarative templates: AWS CodePipeline allows you to define your pipeline structure through a declarative JSON document that specifies your release workflow and its stages and actions. These documents enable you to update existing pipelines as well as provide starting templates for creating new pipelines.

  6. Access control: AWS CodePipeline uses AWS IAM to manage who can make changes to your release workflow, as well as who can control it. You can grant users access through IAM users, IAM roles, and SAML-integrated directories.

  7. Receive Notifications: You can create notifications for events impacting your pipelines. Notifications will come in the form of Amazon SNS notifications. Each notification includes a status message as well as a link to the resources whose event generated that notification.

Concepts of AWS CodePipeline

The main concepts of AWS CodePipeline are:

  1. Pipeline: A pipeline is the workflow definition that describes your application's continuous integration and continuous deployment. You can use stages and actions to define the workflows.

  2. Stage: A stage is one major component in your pipeline. Stages are run in isolated environments and limit the number of parallel changes in that environment. Each stage is made up of several serial or parallel actions.

  3. Action: An action is an operation performed on your application code. This can range from building your application, running integration tests, or deploying to a runtime environment. There is six valid action types - Source, Build, Approval, Deploy, Test, and Invoke.

    • Source can be used to pull source code from Amazon S3, AWS CodeCommit, or using GitHub via a CodeStarSourceConnection.

    • Build, Deploy and Test can use AWS or custom on-prem environments to perform CICD actions.

    • Approval can be used as an intermediate step whenever approval is required.

    • Invoke can be used to invoke other AWS Services like AWS Lambda or AWS StepFunctions.

  4. Transition: A transition marks the point where a pipeline execution moves from one state in the pipeline to the next stage. Transitions can be disabled or enabled between stages.

  5. Artifact: Your application's source code and any other binary files (like dependencies, definition files, etc.) that are required to run your application are called artifacts. These include everything required for your pipeline to function. In a pipeline, artifacts can be the set of files worked on by an action and these are referred to as input artifacts. The final output of a completed action is referred to as output artifacts.

How does AWS CodePipeline works?

How to build a CI/CD pipeline in AWS

When developers commit changes to a source repository, CodePipeline automatically detects the changes. Those changes are built, and if any tests are configured, they are run. After the tests are complete, the built code is deployed to staging servers for testing.

From the staging server, CodePipeline runs more tests (e.g., integration or load tests). Upon the successful completion of those tests, and after the manual approval action that was added to the pipeline is completed, CodePipeline deploys the tested and approved code to production instances.

TASK: Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild, and deploys it to a Deployment Group.

For Creating CodeCommit Repo, Refer the link: AWS CodeCommit
For CodeBuild, Refer the link: AWS CodeBuild
For CodeDeploy, Refer the link: AWS CodeDeploy

Let's dive into the steps for creating a CodePipeline👇

Step 1: Login to AWS Console and on Search bar type "CodePipeline".

Step 2: Go to CodePipeline and on left hand navigation panel, Click on "Pipelines".

Step 3: Click on "Create Pipeline". In Pipeline Settings,

  1. Pipeline name: CodePipeline

  2. Pipeline type: V2

  3. Service role: New Service role

Step 4: Click on Next.

Step 5: In Add Source stage.

  1. Source Provider: AWS CodeCommit

  2. Select Your CodeCommit Repo.

  3. Select the branch name

  4. Change detection option: AWS CodePipeline

  5. Output artifact format: CodePipeline default

Step 6: Click on Next.

Step 7: In Add build stage.

  1. Build Provider: AWS CodeBuild

  2. Select your Project name you have created in CodeBuild.

  3. Build type: Single build

Step 8: Click on Next.

Step 9: In Add deploy stage.

  1. Deploy Provider: AWS CodeDeploy

  2. Select your Application which you have created in AWS CodeDeploy.

  3. Select the deployment group

Step 10: Click on Next.

Step 11: Review the details.

Step 12: Click on "Create Pipeline".

Step 13: Once your pipeline is successfully created, you can see that this pipeline automatically triggers the code thereby automating the process.

And you can see in the above screenshots our pipeline is successfully run.

Step 14: To verify this let us reach our Nginx server via our EC2 instance’s Public IPv4.


In Conclusion, AWS CodePipeline is a fully managed continuous integration and continuous delivery (CI/CD) service provided by Amazon Web Services (AWS). It automates the process of building, testing, and deploying code changes, enabling developers to deliver software updates more efficiently and reliably.

CodePipeline integrates with various AWS services and third-party tools, allowing users to create flexible and customizable workflows for their application release pipelines. With features like easy integration, visual pipeline modeling, and support for multiple deployment stages, AWS CodePipeline streamlines the software release process and helps organizations achieve faster, more predictable delivery of applications.

In this blog, we have created a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild, and deploys it to a Deployment Group.

Hope you find it helpful🤞 So I encourage you to try this on your own and let me know in the comment section👇 about your learning experience.✨

👆The information presented above is based on my interpretation. Suggestions are always welcome.😊

~Smriti Sharma✌