Lambda
list functions
aws lambda list-functions
aws lambda get-function --function-name hello-world-python
You can download the zipfile of the source code with "jq -r '.Code.Location' result.json"
confirm CloudWatch Logs
aws logs describe-log-groups | jq .'logGroups[].logGroupName'
aws logs describe-log-streams --log-group-name /aws/lambda/hello-world-python
aws logs get-log-events --log-group-name /aws/lambda/hello-world-python --log-stream-name '2019/10/05/xxxxxxxx'
create function
aws lambda create-function --function-name hello-world-python \
--runtime python2.7 \
--handler lambda_function.lambda_handler \
--role arn:aws:iam::xxxxxxxx \
--zip-file fileb://../lambda_function.zip
modify function
aws lambda update-function-configuration --function-name hello-world-python --environment '{"Variables":{"key":"value"}}'
aws lambda update-function-code --function-name hello-world-python --zip-file fileb://../lambda_function.zip
invocation
aws lambda invoke --function-name hello-world-python --invocation-type DryRun --payload '{"message":"a b c 1 2 3"}' outfile.tmp
aws lambda invoke --function-name hello-world-python --payload '{"message":"a b c 1 2 3"}' outfile.tmp
delete function
aws lambda list-functions
aws lambda get-function --function-name hello-world-python
aws lambda delete-function --function-name hello-world-python
cloudformation sample template
TestLambda:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: !Ref BucketName
S3Key: "lambda_function.zip"
S3ObjectVersion: !Ref S3ObjectVersion
FunctionName: "TestFunction"
Handler: "lambda_function.lambda_handler"
MemorySize: 128
Role: !GetAtt TestLambdaRole.Arn
Runtime: "python2.7"
Timeout: 3
Tags:
- "Key": "Name"
"Value": "test"