Manage AWS Lambda via CLI
- Create security politics file
- Create aws security role
aws iam create-role \
--role-name lambda-exemplo \
--assume-role-policy-document file://politics.json \
| tee logs/role.log
- Create index.js and zip it
zip function.zip index.js
- Post function on AWS
aws lambda create-function \
--function-name hello-cli \
--zip-file fileb://function.zip \
--handler index.handler \
--runtime nodejs12.x \
--role arn:aws:iam::201807860611:role/lambda-exemplo \
| tee logs/lambda-create.log
- Call Lambda Function
aws lambda invoke \
--function-name hello-cli \
--log-type Tail \
logs/lambda-exec.log
- Update index.js and zip it again
zip function.zip index.js
- Update function on AWS
aws lambda update-function-code \
--zip-file fileb://function.zip \
--function-name hello-cli \
--publish \
| tee logs/lambda-update.log
- Call Lambda Function, and verify changes
aws lambda invoke \
--function-name hello-cli \
--log-type Tail \
logs/lambda-exec-update.log
- Clear AWS environment
aws lambda delete-function \
--function-name hello-cli
aws iam delete-role \
--role-name lambda-exemplo