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.
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
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.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
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.
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
Click to Comment