Skip to content

election-futures-dev/create-lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

create-lambda

Create AWS Lambda using AWS CLI

Prerequisite

  • Install jq to parse the json content into CLI
brew install jq
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
aws configure

Steps to Create Lambda

  • Create Role
# Declare role-name
role_name="lambda-allow-basic"    
# Read the ./allow-role-policy.json.
policy=$(cat ./allow-role-policy.json | jq)
# Create the AWS-IAM role with the name lambda-ex and the above read-in policy. role-name and policy can be customized.
aws iam create-role --role-name $(echo "$role_name") --assume-role-policy-document $policy  
  • Zip the index.js
zip index.zip index.js
  • Create lambda
# Declare function-name & runtime
func_name="this-is-test-lambda"
runtime="nodejs12.x"
# Creae lambda with the func_name. --role ARN must be changed with the one created from the first step.  
aws lambda create-function --function-name $(echo "$func_name") --zip-file fileb://index.zip --handler index.handler --runtime $(echo "$runtime") --role arn:aws:iam::221262875767:role/lambda-allow-basic

About

Create AWS Lambda using AWS CLI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%