Scheduled Lambda Job Module
This module makes it easy to run an AWS Lambda function (such as one created with the lambda module) on a scheduled basis. This is useful for periodic background jobs, such as taking a daily snapshot of your servers.
Background info
For more information on AWS Lambda, how it works, and how to configure your functions, check out the lambda module documentation.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S SCHEDULED-LAMBDA-JOB MODULE
# ------------------------------------------------------------------------------------------------------
module "scheduled_lambda_job" {
source = "git::git@github.com:gruntwork-io/terraform-aws-lambda.git//modules/scheduled-lambda-job?ref=v1.0.2"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The ARN of the lambda function.
lambda_function_arn = <string>
# The name of the lambda function.
lambda_function_name = <string>
# An expression that defines the schedule for this lambda job. For example,
# cron(0 20 * * ? *) or rate(5 minutes).
schedule_expression = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# Set to false to have this module skip creating resources. This weird
# parameter exists solely because Terraform does not support conditional
# modules. Therefore, this is a hack to allow you to conditionally decide if
# this module should create anything or not.
create_resources = true
# JSON text that will be passed to the lambda function on each invoke.
lambda_function_input = null
# The namespace to use for all resources created by this module. If not set,
# var.lambda_function_name, with '-scheduled' as a suffix, is used.
namespace = null
# A map of tags to apply to the event rule.
tags = {}
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S SCHEDULED-LAMBDA-JOB MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-lambda.git//modules/scheduled-lambda-job?ref=v1.0.2"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The ARN of the lambda function.
lambda_function_arn = <string>
# The name of the lambda function.
lambda_function_name = <string>
# An expression that defines the schedule for this lambda job. For example,
# cron(0 20 * * ? *) or rate(5 minutes).
schedule_expression = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# Set to false to have this module skip creating resources. This weird
# parameter exists solely because Terraform does not support conditional
# modules. Therefore, this is a hack to allow you to conditionally decide if
# this module should create anything or not.
create_resources = true
# JSON text that will be passed to the lambda function on each invoke.
lambda_function_input = null
# The namespace to use for all resources created by this module. If not set,
# var.lambda_function_name, with '-scheduled' as a suffix, is used.
namespace = null
# A map of tags to apply to the event rule.
tags = {}
}
Reference
- Inputs
- Outputs
Required
lambda_function_arn
stringThe ARN of the lambda function.
lambda_function_name
stringThe name of the lambda function.
schedule_expression
stringAn expression that defines the schedule for this lambda job. For example, cron(0 20 * * ? *) or rate(5 minutes).
Optional
create_resources
boolSet to false to have this module skip creating resources. This weird parameter exists solely because Terraform does not support conditional modules. Therefore, this is a hack to allow you to conditionally decide if this module should create anything or not.
true
lambda_function_input
stringJSON text that will be passed to the lambda function on each invoke.
null
namespace
stringThe namespace to use for all resources created by this module. If not set, lambda_function_name
, with '-scheduled' as a suffix, is used.
null
tags
map(string)A map of tags to apply to the event rule.
{}
Cloudwatch Event Rule Arn
Cloudwatch Event Rule schedule expression