Deploy AWS Lambda function using Serverless
Serverless basics in 5 min
Manage your serverless applications with less overhead using Serverless Framework.
Install serverless
npm install -g serverless
Configure access to AWS
serverless config credential --provider aws --key *** --secret *** --profile your_profile_name
Create a Lambda Function
sls create --template aws-python --path hello-world-python
Available templates
“aws-clojure-gradle”, “aws-clojurescript-gradle”, “aws-nodejs”, “aws-nodejs-typescript”, “aws-alexa-typescript”, “aws-nodejs-ecma-script”, “aws-python”, “aws-python3”,”aws-groovy-gradle”, “aws-java-maven”, “aws-java-gradle”, “aws-kotlin-jvm-maven”, “aws-kotlin-jvm-gradle”, “aws-kotlin-nodejs-gradle”, “aws-scala-sbt”, “aws-csharp”,”aws-fsharp”, “aws-go”, “aws-go-dep”, “aws-go-mod”, “aws-ruby”, “aws-provided”To check all templates just type "sls create --template" in your console.
The above command will create the following project files.
Open hello-world-python/serverless.yml and edit provider
provider:
name: aws
runtime: python2.7
profile: your_profile_name
region: ap-southeast-1
Deploy
sls deploy -v
Invoke
sls invoke -f hello -l
Update (only the function)
sls deploy function -f hello
Check logs
sls logs -f hello -t
Clean up and remove everything
sls remove
— — —
More . . .
Edit Basic settings (Memory, Timeout)
Function Level
For all the functions (Global)
IAM permission for Lambda functions
Environment Variables (can define function level or provider level)
VPC for Lambda
Resources
Serverless Framework
AWS Lambda
Serverless Forum
Examples
Community Examples