Scheduled Lambda Job Module
View SourceRelease NotesThis 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=v0.21.12"
  # ----------------------------------------------------------------------------------------------------
  # 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=v0.21.12"
}
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_arnstringThe ARN of the lambda function.
lambda_function_namestringThe name of the lambda function.
schedule_expressionstringAn expression that defines the schedule for this lambda job. For example, cron(0 20 * ? ) or rate(5 minutes).
Optional
create_resourcesboolSet 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.
truelambda_function_inputstringJSON text that will be passed to the lambda function on each invoke.
nullnamespacestringThe namespace to use for all resources created by this module. If not set, lambda_function_name, with '-scheduled' as a suffix, is used.
nulltagsmap(string)A map of tags to apply to the event rule.
{}Cloudwatch Event Rule Arn
Cloudwatch Event Rule schedule expression