Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

comtravo/terraform-aws-lambda

Repository files navigation

Terraform AWS module for AWS Lambda

Introduction

This module creates an AWS lambda and all the related resources. It is a complete re-write of our internal terraform lambda module.

Usage

Checkout examples on how to use this module for various trigger sources.

Authors

Module managed by Comtravo.

License

MIT Licensed. See LICENSE for full details.

Requirements

Name Version
terraform >= 0.13
aws ~> 3.0

Providers

Name Version
aws ~> 3.0

Modules

Name Source Version
cloudwatch-log-subscription ./log_subscription/ n/a
sqs_external ./triggers/sqs_external/ n/a
triggered-by-api-gateway ./triggers/api_gateway/ n/a
triggered-by-cloudwatch-event-schedule ./triggers/cloudwatch_event_schedule/ n/a
triggered-by-cloudwatch-event-trigger ./triggers/cloudwatch_event_trigger/ n/a
triggered-by-cloudwatch-logs ./triggers/cloudwatch_logs/ n/a
triggered-by-cognito-idp ./triggers/cognito_idp/ n/a
triggered-by-sqs ./triggers/sqs/ n/a
triggered-by-step-function ./triggers/step_function/ n/a
triggered_by_kinesis ./triggers/kinesis/ n/a

Resources

Name Type
aws_cloudwatch_log_group.lambda resource
aws_lambda_function.lambda resource

Inputs

Name Description Type Default Required
cloudwatch_log_retention Enable Cloudwatch logs retention number 90 no
cloudwatch_log_subscription Cloudwatch log stream configuration
object({
enable : bool
filter_pattern : string
destination_arn : string
})
{
"destination_arn": "",
"enable": false,
"filter_pattern": ""
}
no
description Lambda function description string "Managed by Terraform" no
environment Lambda environment variables map(string) null no
file_name Lambda function filename name string null no
function_name Lambda function name string n/a yes
handler Lambda function handler string null no
image_config Container image configuration values that override the values in the container image Dockerfile.
object({
command = list(string)
entry_point = list(string)
working_directory = string
})
null no
image_uri ECR image URI containing the function's deployment package string null no
kinesis_configuration https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping
map(object({
batch_size = number
bisect_batch_on_function_error = bool
destination_config__on_failure__destination_arn = string
event_source_arn = string
maximum_batching_window_in_seconds = number
maximum_record_age_in_seconds = number
maximum_retry_attempts = number
parallelization_factor = number
starting_position = string
starting_position_timestamp = string
tumbling_window_in_seconds = number
}))
{} no
layers List of layers for this lambda function list(string) [] no
memory_size Lambda function memory size number 128 no
publish Publish lambda function bool false no
region AWS region string n/a yes
reserved_concurrent_executions Reserved concurrent executions for this lambda function number -1 no
role Lambda function role string n/a yes
runtime Lambda function runtime string "nodejs14.x" no
s3_bucket S3 bucket name where lambda package is stored string null no
s3_key S3 key where lambda package is stored string null no
s3_object_version S3 object version of the lambda package string null no
sqs_external External SQS to consume
object({
batch_size = number
sqs_arns = list(string)
})
null no
tags Tags for this lambda function map(string) {} no
timeout Lambda function runtime number 300 no
tracing_config https://www.terraform.io/docs/providers/aws/r/lambda_function.html
object({
mode : string
})
{
"mode": "PassThrough"
}
no
trigger Trigger configuration for this lambda function any n/a yes
vpc_config Lambda VPC configuration
object({
subnet_ids : list(string)
security_group_ids : list(string)
})
{
"security_group_ids": [],
"subnet_ids": []
}
no

Outputs

Name Description
arn AWS lambda arn
aws_lambda_function AWS lambda attributes
dlq AWS lambda Dead Letter Queue details
function_name AWS lambda function name
invoke_arn AWS lambda invoke_arn
qualified_arn AWS lambda qualified_arn
queue AWS lambda SQS details
sns_topics AWS lambda SNS topics if any
version AWS lambda version