About Girish Bhatia
I am an AWS Cloud Technology Enthusiast & Technology Program Delivery Leader. I love to
deliver cloud-based software solution in alignment with strategic goals for business &
technology modernization.
Qualifications:
❏Master of Science in Computer Information Systems
❏AWS Certified Developer Associate | Amazon Web Services
❏AWS Certified Solution Architect Associate | Amazon Web Services
❏AWS Certified Cloud Practitioner | Amazon Web Services
❏AWS Badges : Serverless, Solution Architecture
❏Microsoft Certified: Azure Fundamental
❏Microsoft Certified professional: Solution Architecture
❏Microsoft Certified .NET Solution Developer
❏Project Management Professional (PMP)
❏Certified Scrum Master (Scrum Alliance)
IT Experience:
❏20+ years in IT
❏Tech Program Delivery -Tech Mod/Cloud Transformation
❏Software Development Python, Java, .NET, Oracle, APIs, BI tools
❏in telecom, public/state system, banking/finance domain.
❏Onshore/offshore software delivery
❏Tech Program/Project Management
❏Journey to Cloud, Tech Modernization
❏On Prim to Cloud Migration
❏Cloud/API Integration B2B
❏Data Center planning/Mainframe relocation/upgrades
https://cloudwithgirish.com@CloudWithGirish
What we are building today?
Develop, Test and Debug Lambda function locally
Let's learn how to make Lambda functions using AWS SAM in VSCode. We'll start with a demo, then create a
function that gives back a state name when you input a state code. We'll set up debugging in VSCode, test the
function locally, and once it works as expected, deploy it to AWS using SAM deploy.
Tools & Services
•Environment Setup
•VSCode+ AWS Toolkit + SAM demo
•Build getState function
•Use Python dictionary
•Build
•Invoke locally
•Debug
•Deploy the function
•SAM uses CloudFormation to create a stack.
•S3 bucket is created for the artifacts
•SAMConfig file is created, can be customized
by developer
Architecture Pattern
Know your budget and watch your cost!
•Setup Budget
•Familiarize yourself with cost explorer
Quick Demo
In VSCode, Navigate to AWS Toolkit
Right Click on Lambda
Quick Demo
Select Python 3.12
Quick Demo
Select AWS SAM Hello World
Quick Demo
Select a Folder to save your code
Name your app
Quick Demo
Open the app folder and look at few files (event.json. Template.yaml. App.py)
Quick Demo
Build the code using SAM Build
sam Build
Invoke the function
sam local invoke HelloWorldFunction-e events/event.json
Review output.
Make change to the function, build, and run again!
Let's invoke now as API
Run the API locally
sam local start-api
Open postman or a browser and test the function!
Serverless Application Model
&
Lambda Function
Steps to create & invoke Lambda function locally
oCreate src and events folder
oCreate Lambda function
oCreate template.yaml
oCreate event.json
osam build
osam local invoke
Lambda Function (python)Partial code!
Full src code in git repo
Template.yaml
Event.json
SAM Commands
# build your lambda
sam build
# invoke lambda locally
sam local invoke <functionName> -e <location of the event.json>
sam local invoke getStateFn-e events/event.json
Build Function
Function Output
VSCode Debug
Debug does not work!
Add debug configuration
–launch.json
Debug in action
Lambda function developed locally, what’s next?
oDeploy it using SAMoSAM uses CloudFormation to create a stack.oS3 bucket is created for the artifactsoa SAMConfig file is created
oCommand is –> sam deploy --guided
AWS SAM Commands Reference
osam buildosam local generate-event apigatewayaws-proxyosam local invoke <function > -e <event json >osam local start-apiosam deploy –guidedosam deploy ( update stack )osam deleteoaws cloudformation delete-stack --stack-name your-stack-name
Delete the stack so that you don’t incur charges!
osam deleteoaws cloudformation delete-stack --stack-name getStateApp