A standalone tool for AWS lambda functions that can among other things deploy and delete them.
This is a CLI tool written in Go that is meant to be able to do simple operations on AWS lambda functions.
Currently the available operations are:
- Deploy a lambda
- List deployed lambdas
- Delete a lambda
- Invoke a lambda
- Show lambda statistics
The main purpose of this tool is to deploy lambdas, and be used in a deployment pipeline.
This tool can be used to deploy pre-built lambda functions. Provide the tool the zip/jar file, and a descriptor to deploy the lambda function.
The tool can be downloaded from the releases page:
https://github.com/pbthorste/aws-lambda-tool/releases
The tool uses amazon profiles as defined by the amazon cli tool (https://aws.amazon.com/cli). You can either install the cli tool, or manually create the files:
- ~/.aws/config
- ~/.aws/credentials
By default the tool will use the default profile / region.
It can also read this info from environment variables:
- AWS_REGION
- AWS_PROFILE
Or you can give the region/profile as an argument into the script:
lambdatool --region REGION --profile PROFILEYou need:
- A zip file containing the lambda function
- A descriptor file
Then you can run:
lambdatool deploy -d lambda.yml -z lambda.zipLambda functions need to have an IAM role, and it must be set in the descriptor. This tool does not create IAM roles - but multiple other tools do, such as:
But in order to get started, you could create a basic IAM role that will allow the lambda function to send logs to cloudwatch. Create a role and give it this policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:PutLogEvents",
"logs:CreateLogStream"
],
"Resource": "arn:aws:logs:*:<your account id>:*"
}
]
}You might want to have a more restrictive policy in production environments.
The tool reads a yaml descriptor with settings for the lambda. or valid values for the configuration items, see the documentation from Amazon. http://docs.aws.amazon.com/lambda/latest/dg/welcome.html
filename: lambda.yml
See:
lambda:function_name: aws-lambda-java-exampledescription: java hello worldhandler: com.example.lambda.Handlerruntime: java8# TODO: Fix the account number, and create the rolerole: arn:aws:iam::<fix me>:role/basic-lambda-rolelambda:function_name: node-js-appdescription: node-js hello worldhandler: index.handlerruntime: nodejs4.3role: arn:aws:iam::<account id>:role/basic-lambda-rolememory_size: 128timeout: 60publish: falseenvironment:envVar: valuelambda:function_name: python-hellodescription: python hello worldhandler: python_hello.handlerruntime: python2.7role: arn:aws:iam::<account id>:role/basic-lambda-rolememory_size: 128timeout: 60publish: falseenvironment:envVar: value