This Terraform module provisions:
- Lambda Function
- Lambda Function Event Invoke Config
- CloudWatch Log Group
- CloudWatch Alarm for Lambda Errors
- IAM Role
- IAM Policy
name- Name that should be used for the Lambda function and related resourcessource_dir- Local directory containing the source code for the Lambda Functionfilename- ZIP file containing the source code for the Lambda Functionhandler- The entrypoint that should be called when the Lambda function is invoked (Default:lambda_function.lambda_handler)runtime- Runtime that should be used for the Lambda function (Default:python3.7)layers- List of Lambda layers that should be attached to the Lambda functionmemory_size- Amount of memory that should be configured for the Lambda functiontimeout- Timeout for the Lambda function (Default:30)environment- Environment configuration for the Lambda functionvpc_config- VPC Config for the Lambda functiondead_letter_config- Dead letter configuration for the Lambda functiontags- Tags that should be applied to all resources in this moduleretention_in_days- Retention period for log messages in days (Default:30)policy_statements- IAM Policy Statements that should be applied to the Lambda functionerror_actions_enabled- Whether error alarm actions should be enabled or not (Default:true)error_insufficient_data_actions- Actions that should be performed in case the error alarm is in the insufficient data state (Default:[])error_alarm_actions- Actions that should be performed in case the error alarm is in the alarm state (Default:[])error_ok_actions- Actions that should be performed in case the error alarm is in the ok state (Default:[])reserved_concurrent_executions- The amount of reserved concurrent executions for the Lambda function (Default:-1, which means no limit)create_cloudwatch_alert- Whether a CloudWatch alert for Lambda errors should be created or not (Default:true)
module "lambda_function" {
source = "git::https://github.com/albumprinter/infra-terraform-modules.git//modules/aws/lambda_function?ref="
name = "${var.project_name}Lambda"
source_dir = "${path.module}/src"
tags = var.tags
}module "lambda_function" {
source = "git::https://github.com/albumprinter/infra-terraform-modules.git//modules/aws/lambda_function?ref="
name = "${var.project_name}Lambda"
filename = "lambda.zip"
policy_statements = [
{
"Effect" : "Deny",
"Action" : [
"s3:ListBucket"
],
"Resource" : ["*"]
}
]
tags = var.tags
}module "lambda_function" {
source = "git::https://github.com/albumprinter/infra-terraform-modules.git//modules/aws/lambda_function?ref="
name = "${var.project_name}Lambda"
source_dir = "${path.module}/src"
vpc_config = {
subnet_ids = data.aws_subnet_ids.private.ids,
security_group_ids = [aws_security_group.this.id]
}
tags = var.tags
}module "lambda_function" {
source = "git::https://github.com/albumprinter/infra-terraform-modules.git//modules/aws/lambda_function?ref="
name = "${var.project_name}Lambda"
source_dir = "${path.module}/src"
environment = {
variables = {
TEST = "test"
}
}
tags = var.tags
}module "lambda_function" {
source = "git::https://github.com/albumprinter/infra-terraform-modules.git//modules/aws/lambda_function?ref="
name = "${var.project_name}Lambda"
source_dir = "${path.module}/src"
dead_letter_config = {
target_arn = aws_sqs_queue.dead_letter.arn
}
tags = var.tags
}archive_fileaws_lambda_functionaws_cloudwatch_log_groupaws_iam_roleaws_iam_policyaws_cloudwatch_metric_alarm_errors