Build CI/CD for AWS Lambda Functions using Jenkins and the Serverless Framework

Build CI/CD for AWS Lambda Functions using Jenkins and the Serverless Framework

Serverless architectures are application designs that incorporate third-party services, and/or that include custom code run in managed, ephemeral containers on a "Functions as a Service" (FaaS) platform. This project enables deployment of serverless services over AWS using Jenkins.

So, Our Jenkins Job will be triggered by GitHub whenever we push the code into GitHub Repo. Jenkins's job is configured by starting with cloning the code from SCM. Then, building it with the specified build information of the applications from SAM Template files.

By running the Unit test of the code, the Application codebase can be tested and validated before it gets deployed into AWS Lambda. Then, Jenkins will deploy the Lambda application in the AWS Platform by Jenkins AWS SAM plugin. So, whenever we push any update on the Lambda function, this pipeline will automatically get triggered and the entire workflow will be executed and finally it will automatically be deployed again to the AWS platform.

Let's Prepare for the Setup. So, To set up the complete workflow, we need to do the following actions:

  1. Creating AWS Service Roles
  2. Application Setup
  3. Jenkins Pipeline setup

Features:

  • Selective deployment over AWS
  • Automated build and deployment using Jenkins
  • Version control using git
  • Security using Jenkins vaults
  • This framework is very effective in deploying serverless applications
  • A simpler design for maintaining and controlling deployment artefacts
  • Amazon web services are a cloud service provider that provides SaaS/PaaS/IaaS services overcloud. It provides a wide range of serverless services which include lambda, step functions, lex, cloud watch, s3, ECS, EKS, etc.
  • Lambda functions: AWS Lambda is a serverless compute service that runs the code in response to events and automatically manages the underlying computing resources.
  • Step function: AWS Step Functions is a web service that enables you to coordinate the components of distributed applications and microservices using visual workflows.
  • Cloudwatch: It helps you collect and access all performance and operational data in the form of logs and metrics from a single platform.
  • S3: Simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web.
  • AWS CLI: AWS command-line interface is a unified tool to manage and control AWS services.

Create a Jenkins Pipeline

Jenkins is an open-source automation server that enables developers around the world to reliably build, test, and deploy their software. Jenkins is used to setup a pipeline for automated deployment over AWS.

Continuous Integration/Continuous Delivery (CICD): It lays out some practices to follow in order for the code you write to more quickly and safely get to your users and ultimately generate value.

Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines into Jenkins. The pipeline provides an extensible set of tools for modelling simple-to-complex delivery pipelines "as code" via the Pipeline DSL.

Jenkins pipeline job: Jenkins supports different kinds of jobs such as freestyle, pipeline, multi-branch pipelines, etc. In this project, we have created a pipeline job.

By doing this project you will learn about serverless computing is a method of providing backend services on an as-used basis. It decouples the application and the infrastructure for developing a lightweight code called as Functions-as-a-service(FaaS). Amazon web services offer a number of services to govern the serverless computing model. This project automates the deployment of such serverless components over AWS. Services this project supports include - Lambda functions, Step functions, Cloudwatch & s3. Build and deployment of these components are governed using Jenkins declarative pipelines which pulls source code from GIT and deploys it into AWS. Sensitive information is kept in Jenkins vaults and can be fetched into the pipeline at runtime using Jenkins provided plugins.

The project can be explained clearly in below steps in modules.

1. Introduction
2. AWS
3. GIT
4. Create a Jenkins Pipeline
5. Pipeline Elements/Sections
6. Selective deployment
7. Security in Jenkins
8. Deployment
9. Conclusion
10. Resources
11. Module Test

SkillPractical AWS Learning path gives a structure to training programs. This learning path is designed for individuals who want to learn how to use the most common topics in AWS. They will cover in a step by step procedure from beginner to advanced.

Rate this article

No Comments

Leave a Comment