Skip to main content
Version: v13.4.0

Develop Lambda Functions

Develop a new Cumulus Lambda

AWS provides great getting started guide for building Lambdas in the developer guide.

Cumulus currently supports the following environments for Cumulus Message Adapter enabled functions:

Additionally you may chose to include any of the other languages AWS supports as a resource with reduced feature support.

Deploy a Lambda

Node.js Lambda

For a new Node.js Lambda, create a new function and add an aws_lambda_function resource to your Cumulus deployment (for examples, see the example in source example/lambdas.tf and ingest/lambda-functions.tf) as either a new .tf file, or added to an existing .tf file:

resource "aws_lambda_function" "myfunction" {
function_name = "${var.prefix}-function"
filename = "/path/to/zip/lambda.zip"
source_code_hash = filebase64sha256("/path/to/zip/lambda.zip")
handler = "index.handler"
role = module.cumulus.lambda_processing_role_arn
runtime = "nodejs10.x"

vpc_config {
subnet_ids = var.subnet_ids
security_group_ids = var.security_group_ids
}
}

Please note: This example contains the minimum set of required configuration.

Make sure to include a vpc_config that matches the information you've provided the cumulus module if intending to integrate the lambda with a Cumulus deployment.

Java Lambda

Java Lambdas are created in much the same way as the Node.js example above.

The source points to a folder with the compiled .class files and dependency libraries in the Lambda Java zip folder structure (details here), not an uber-jar.

The deploy folder referenced here would contain a folder 'test_task/task/' which contains Task.class and TaskLogic.class as well as a lib folder containing dependency jars.

Python Lambda

Python Lambdas are created the same way as the Node.js example above.

Cumulus Message Adapter

For Lambdas wishing to utilize the Cumulus Message Adapter(CMA), you should define a layers key on your Lambda resource with the CMA you wish to include. See the input_output docs for more on how to create/use the CMA.

Other Lambda Options

Cumulus supports all of the options available to you via the aws_lambda_function Terraform resource. For more information on what's available, check out the Terraform resource docs.

Cloudwatch log groups

If you want to enable Cloudwatch logging for your Lambda resource, you'll need to add a aws_cloudwatch_log_group resource to your Lambda definition:

resource "aws_cloudwatch_log_group" "myfunction_log_group" {
name = "/aws/lambda/${aws_lambda_function.myfunction.function_name}"
retention_in_days = 30
tags = { Deployment = var.prefix }
}