Create and understand types of events in CodePipeline with SNS

Lab Details

  1. This lab walks you through the Deployment of sample Node.js application stored in S3 Bucket via CodePipeline. You will first create a sample Node.js application with Elastic Beanstalk, then overrides using CodePipeline.

  2. You will also create an SNS topic with email as a subscription and CloudWatch event for the same.

  3. Duration: 90 minutes

  4. AWS Region: US East (N. Virginia) us-east-1


What is AWS CodePipeline?

  1. AWS CodePipeline helps you in modeling, visualizing, and automating the steps required to continuously deliver the release of your software.

  2. Using AWS CodePipeline, you can create and configure various stages of a software release process. It helps you automate the delivery of software having a frequent release.

  3. AWS CodePipeline can help you do various tasks, such as

    • Automating release process of software delivery

    • View Pipeline history details

    • Customize the stages and action

    • Choose the source, build and deploy stage.

    • Add the manual approval for the release process.

    • Integration with various AWS Services.

  4. AWS CodePipeline at a glance.

  5. Source: A place where source code with its revisions is stored. It can be Amazon S3 Bucket, CodeCommit repository, or Git-based repositories such as GitHub and Bitbucket.

  6. Build: In this phase, the buildspec.yml file plays a very important role. This is the phase where software is tested and build. 

  7. Staging: A place where code is deployed into a testing environment or also called a pre-production environment. You use this phase to test the software before making it live for public users. This is an optional stage if the application is well tested before uploading to the source.

  8. Manual approval: This phase helps software engineers to get the approval for the code, deployed and well tested into the testing environment. It uses SNS to get the approvals on the email. This is the optional stage.

  9. Deploy: The last phase for the delivery of software. Using AWS CodePipeline, applications can be deployed on Amazon EC2 Instances using CodeDeploy, Elastic Beanstalk, or AWS OpsWorks Stacks. 

Types of events supported by AWS CodePipeline

  1. As you can see in the below snapshot of events for the CodePipeline service, there are 5 types of events that are supported. Let's understand each of them, one by one.
  2. All Events: By selecting this option, it will notify you of all the changes you do with your CodePipeline pipeline.
  3. AWS API Call via CloudTrail: This option will look for the activities in the CloudTrail trail and notify you. But read-only APIs are not supported here. Expect this type, you can perform all the other 4 events with this lab. 
  4. CodePipeline Pipeline Execution State Change: With this option, you will be notified of all the stage changes of all the pipelines or specified pipelines.
  5. CodePipeline Stage Execution State Change: Here, you will be notified of all the stages or specified stage of all the pipelines or specified pipelines.
  6. CodePipeline Action Execution State Change: By choosing this option, you will be notified of all the actions or specified actions of all the stages of specified stages of all the pipelines or specified pipelines.
  7. To read more about events of AWS CodePipeline, do check out the official documentation here :

Architecture Diagram

Task Details

  1. Launching Lab Environment

  2. Create SNS Topic

  3. Subscribe to SNS Topic

  4. Create CloudWatch events

  5. Create Elastic Beanstalk Environment

  6. Copy the object key of an S3 object

  7. Create a CodePipeline pipeline

  8. Test the application deployment changes

  9. Check the notification of events in the mailbox

  10. Deleting AWS resources