AWS, Cloud Computing, DevOps

2 Mins Read

Step by Step Procedure for Automating Lambda Deployment using Jenkins

Amazon provides end-to-end solutions for continuous integration and continuous deployment where its services like AWS CodeCommit, AWS CodeDeploy can be leveraged. You can also install Jenkins on EC2 and automate the deployments.

Jenkins is a great open-source automation server; Jenkins provides hundreds of plugins to support building, deploying, and automating any project. Here we are going to discuss the approach where Jenkins is used as a simple CI server and to automate the AWS Lambda invocation and deployment

We are leveraging a plugin that will help us to have the above use case achieved.

Flow Diagram:

Lambda

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Prerequisites:

Follow the official documentation to have it installed: Jenkins running on EC2

Step by Step Guide:

Step 1: AWS Lambda plugin installation

  1. Search and install for AWS Lambda plugin in available plugins by clicking Manage Jenkins and Manage Plugins
    Lambda
    LambdaLambda

Step 2: IAM Set up

  1. For deployment and invocation, we need access to the GetFunction, CreateFunction, UpdateFunctionCode and UpdateFunctionConfiguration, InvokeFunction
  2. We need access to iam:PassRole to attach a role to the Lambda.
  3. Replace ACCOUNTID, FUNCTIONROLE accordingly in the policy. This Instance profile role with policy can be attached to the EC2 instance on which Jenkins is running.

Step 3: Jenkins Job Configuration

  1. Create a Maven project with Java source code repo details.
  2. Build and test code as per requirement
  3. In post-build steps add AWS Lamba deployment
  4. Configure required details like AWS Region, Function Name, Role, zip location (generated jar which is built). AWS keys are not required as we are using the Instance role
  5. We can also configure environment variables, subnets if we configure lambda within VPC. Please check Use Instance credentials to have instance role leveraged
  6. Done!!! Save and Build Job to have your lambda created

Conclusion:

By following the above process, you can have continuous deployment into our lambda functions wherever there is a code change with test cases and code quality checks.

For more DevOps, and CICD content, stay tuned to this page. If you have any queries about the CICD process, post them in the below comment section and I will get back to you at the earliest.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is Microsoft Gold Partner, AWS Advanced Consulting Partner, and a Google Cloud Partner and has successfully led many AWS-related implementation projects for our esteemed clients. So, get in touch with us for quick results.
Feel free to drop a comment or any queries that you have regarding cloud migration, and we will get back to you quickly. To get started, go through our Expert Advisory page and Managed Services Package that is CloudThat’s offerings.

WRITTEN BY Chandan B

Chandan B works as a Project Head - DevOps & Kubernetes at CloudThat for the past five years. He is a multi-cloud certified DevOps professional, helping our clients to migrate, modernize and containerize their workload on the cloud by implementing standard DevOps best practices.

Share

Comments

  1. Pranay

    Jun 25, 2022

    Reply

    I need a declarative pipeline script to take the configuration files from bitbucket and replace the existing files in the lambda. Please guide

  2. Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!