Lambda layers
Added support for Lambda layers:
locals {
artifact = "${path.module}/../build/distributions/java-sqs-lambda.zip"
libraries = "${path.module}/../build/distributions/libraries.zip"
}
data "aws_sqs_queue" "primary" {
name = "cms-updates-primary"
}
resource "aws_lambda_layer_version" "libraries" {
filename = local.libraries
layer_name = "libraries"
compatible_runtimes = ["java11"]
}
module "lambda" {
source = "moritzzimmer/lambda/aws"
version = "5.3.0"
description = "Java lambda with SQS trigger and lambda layers"
filename = local.artifact
function_name = "java-sqs-example"
handler = "example.Handler"
layers = [aws_lambda_layer_version.libraries.arn]
memory_size = 1024
log_retention_in_days = 1
runtime = "java11"
source_code_hash = filebase64sha256(local.artifact)
event = {
type = "sqs"
event_source_arn = data.aws_sqs_queue.primary.arn
}
}