DEV Community

GargeeBhatnagar for AWS Community Builders

Posted on • Edited on

Automate the Experience of Lambda Versioning with Configuration Change and Code Change Using CloudFormation and Code Pipeline

“ I have checked the documents of AWS to automate the experience of lambda versioning with change in configuration and code. I have checked for AWS code pipeline service which makes the process easy and automates for everyone. The Pricing of Code pipeline is based on when the pipeline runs. Also price for code build. ”

A keyword define "Devtron" play an important role in sorting the complexity of DevOps, AppOps and Kubernetes. Also "GitHub" helps to integrate and automate. Both Devtron and GitHub is an open source one.

In this post, you will experience the automation of lambda versioning with configuration and code change using cloudformation and code pipeline. Here I have created a code pipeline to automate lambda creation and its versioning with change in set parameters using cloud formation with artifacts to be stored in s3 bucket.

Prerequisites

You’ll need a Github account and git installed on a local machine. You’ll need AWS CLI installed and configured on your local machine.

Architecture Overview

Image description
The architecture diagram shows the overall deployment architecture with data flow, code build, code deploy, code pipeline, s3, sns, cloud formation, lambda.

Solution overview

The blog post consists of the following phases:

  1. Create of IAM Role, S3 Bucket, Buildspec.yml, Template.yaml and Sample HelloWorld.js File
  2. Create of CodePipeline and Build Project
  3. Create SNS Topic with Subscription and Check of CloudFormation with Lambda Creation
  4. Testing of Lambda Configuration Parameters and Code Deploy while Updating in GitHub

Phase 1: Create of IAM Role, S3 Bucket, Buildspec.yml, Template.yaml and Sample HelloWorld.js File

  1. Open the IAM Console and create a role for cloudformation with AWS lambda execute policy and inline policy with required permission. Create an S3 bucket named as lambda-ci-cd-demo-test. Also configure buildspec.yml file, template.yaml file and helloworld.js file as per the requirement to build a lambda code and configuration part. Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description

Phase 2: Create of CodePipeline and Build Project

  1. Open codepipeline console and create a pipeline with source as github and provider as cloudformation with default IAM role and custom s3 inline policy to be attached with the role. Also build a project with custom settings. Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description

Phase 3: Create SNS Topic with Subscription and Check of CloudFormation with Lambda Creation

  1. Open the Amazon Simple Notification Service and create a topic with subscription for approval notification in the code pipeline. In the code pipeline the stages as source, build, deploy as createchangeset, approvechangeset, executechangeset. Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description

Phase 4: Testing of Lambda Configuration Parameters and Code Deploy while Updating in GitHub

  1. Test the lambda configuration and code in doing changes on various parameters in github. Image description Image description Image description Image description Image description Image description

Clean-up

Delete Code Pipeline, Code Build, IAM Role, S3 Bucket, Cloud Formation, SNS.

Pricing

I review the pricing and estimated cost of this example.

Cost of Code Build = $0.0

Cost of Lambda = $0.0

Cost of Simple Notification Service = $0.0

Cost of Simple Storage Service = $1.0

Total Cost = $(0.0 + 0.0 + 0.0 + 1.0) = $1.0

Summary

In this post, I showed “how to automate the experience of lambda versioning with configuration change and code change using cloudformation and code pipeline”.

For more details on AWS CodeDeploy, Checkout Get started AWS CodeDeploy, open the AWS CodeDeploy console. To learn more, read the AWS CodeDeploy documentation. For more details on AWS CodePipeline, Checkout Get started AWS CodePipeline, open the AWS CodePipeline console. To learn more, read the AWS CodePipeline documentation.

For more details on AWS CodeBuild, Checkout Get started AWS CodeBuild, open the AWS CodeBuild console. To learn more, read the AWS CodeBuild documentation. For more details on AWS CloudFormation, Checkout Get started AWS CloudFormation, open the AWS CloudFormation console. To learn more, read the AWS CloudFormation documentation.

For more details on Devtron and GitHub, Checkout Links:
Devtron Website
GitHub Repo
Join the Discord Community
Follow on Twitter
Raise feature requests, suggest enhancements, report bugs
Read Devtron Blog

Lets quickly adopt and try it! And post the response using #AdoptK8sWithDevtron #devtron

The above blog is submitted as part of 'Devtron Blogathon 2022' - https://devtron.ai/
Check out Devtron's GitHub repo - https://github.com/devtron-labs/devtron/ and give a ⭐ to show your love & support.
Follow Devtron on LinkedIn - https://www.linkedin.com/company/devtron-labs/ and Twitter - https://twitter.com/DevtronL/, to keep yourself updated on this Open Source project.

Thanks for reading!

Connect with me: Linkedin
Image description

Top comments (0)