How to Build and verify an application using aws codepipeline and creating custom events with lambda

For few applications, updates will be released frequently to easy user interaction, performance, usage. They need to check all the cases(Design, module working flows) are working fine in all the test cases. So we need to run the test cases to check the functionality of all the module work flows. After verifying the test cases, we need to update the code to live server. We’re having a series of steps before releasing a software. In such case, AWS code pipeline will be used for running the test cases, verifying the test cases, updating the live with the updates.

AWS Code pipeline will be used for automating all the required steps to release the application updates. We can also use it in different stages like development(staging), live server. So different pipelines will be there for development and live server.

In this blog post, after updating the code pipeline will be run, and it’ll check for application status, send an email if the status is 200. 

Steps to deploy an application with AWS code pipeline:

  • Visit aws codepipeline console(https://console.aws.amazon.com/codepipeline/home)
  • Enter the pipeline name
  • Next, it’ll ask for source provider i.e your code locator for ex: Github, S3. Choose any of the option
  • In this blog post, we’re deploying it from the github, choose github. Click on connect to github
  • After connecting with GitHub, choose your application repository and branch, click on Next Step
  • Select Build Provider as AWS Code Build, choose any of the application in code builder, click on NEXT.
  • Choose deploy as No Deploy, because we’re not deploying the code.
  • Choose  AWS-CodePipeline-Service to give permissions for codepipeline
  • click on create a pipeline to create a pipeline.

Now It’ll run the test cases and verify it. Return success message if the test cases are passed otherwise returns failed message

We need to add an AWS Lambda service to create a custom event for sending notification emails if application status returns 200.

Steps to create a lambda service:

     install boto -t . -- This will install the requirements with in the folder.
cd /mails/ zip -r -D mails.zip *
  • Create a folder with name mails and the new file(sending_email.py) in the folder
  • Install the required packages in the folder using pip
  • Write a script for sending the mail using aws ses service in sending_email.py.
  • Create a zip folder with the following command:
  • Go to aws Lambda console(https://console.aws.amazon.com/lambda/home)
  • Click on Create Function
  • Give function name, programming language details, a role for the function. It’ll create a new function
  • In the Function Code block, Choose entry type as Upload a .zip file, click on upload
  • After the save the function, test it.
  • It will return the response if required packages are installed, otherwise, it’ll return a detailed error message

Now we need to link aws lambda to the aws codepipeline. For that click on edit in the pipeline view page.

  • Click on add new stage && add new action
  • Choose action category as Invoke, Give a name to a particular action, choose lambda
  • Select AWS Lambda Function name, and the parameters if it is required, click on add action.
  • It’ll add to the codepipeline, run the script for every pipeline from now onwards.

Posted On 30 October 2018 By MicroPyramid


Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Configuring and Testing Load Balancer in AWS EC2

When You have an application that is serving Huge Customer Base, so will be your Traffic. Sometimes The Application simply stops responding. We can use ...

Continue Reading...
Amazon AWS IAM Roles and Policies

When You want to Provide access to Amazon Web Services Console or if you're planning to provide REST API Keys to your Developers of a ...

Continue Reading...
How to process message queuing system by amazon SQS

Amazon Simple Queue Service (Amazon SQS) is a distributed messaging queue oriented service.
Queued items in SQS are called messages which are variable in size ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties