Voiced by Amazon Polly |
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.
Freedom Month Sale — Upgrade Your Skills, Save Big!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
Flow Diagram:
Prerequisites:
Follow the official documentation to have it installed: Jenkins running on EC2
Step by Step Guide:
Step 1: AWS Lambda plugin installation
- Search and install for AWS Lambda plugin in available plugins by clicking Manage Jenkins and Manage Plugins
Step 2: IAM Set up
- For deployment and invocation, we need access to the GetFunction, CreateFunction, UpdateFunctionCode and UpdateFunctionConfiguration, InvokeFunction
- We need access to iam:PassRole to attach a role to the Lambda.
123456789101112131415161718192021222324252627282930{"Version": "2012-10-17","Statement": [{"Sid": "Stmt1432812345671","Effect": "Allow","Action": ["lambda:GetFunction","lambda:CreateFunction","lambda:UpdateFunctionCode","lambda:UpdateFunctionConfiguration","lambda:InvokeFunction"],"Resource": ["arn:aws:lambda:REGION:ACCOUNTID:function:FUNCTIONNAME"]},{"Sid": "Stmt14328112345672","Effect": "Allow","Action": ["iam:Passrole"],"Resource": ["arn:aws:iam::ACCOUNTID:role/FUNCTIONROLE"]}]}
- 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
- Create a Maven project with Java source code repo details.
- Build and test code as per requirement
- In post-build steps add AWS Lamba deployment
- 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
- We can also configure environment variables, subnets if we configure lambda within VPC. Please check Use Instance credentials to have instance role leveraged
- 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.
Freedom Month Sale — Discounts That Set You Free!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

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.
Pranay
Jun 25, 2022
I need a declarative pipeline script to take the configuration files from bitbucket and replace the existing files in the lambda. Please guide