=============================
This module can be used to deploy an AWS Lambda function which is scheduled to run on a recurring basis.
lambda_name
- Unique name for Lambda functionmemory_size
(optional) - Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128.runtime
- A valid Lambda runtime environmentlambda_zipfile
- path to zip archive containing Lambda functionsource_code_hash
- the base64 encoded sha256 hash of the archive file - see TF archive file providerhandler
- the entrypoint into your Lambda function, in the form offilename.function_name
schedule_expression
- a valid rate or cron expressioniam_policy_document
- a valid IAM policy document used for the Lambda's execution roletimeout
- (optional) the amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limitssubnet_ids
(optional) - If set, the lambda will be deployed inside a VPC on the subnet(s) specified. Expects a comma separated list of valid AWS subnet ids.security_group_ids
(optional) - If set, the lambda will be deployed inside a VPC and use the security groups specified. Expects a comma separated list of valid VPC security group ids .enabled
- boolean expression. If false, the lambda function and the cloudwatch schedule are not set. Defaults totrue
.
data "aws_iam_policy_document" "create_snaps" {
statement {
sid = "1"
actions = [
"ec2:DescribeVolumes",
"ec2:CreateSnapshot",
"ec2:CreateTags",
]
resources = [
"*",
]
}
}
data "archive_file" "myfunction" {
type = "zip"
source_file = "/valid/path/to/myfunction.py"
output_path = "/valid/path/to/myfunction.zip"
}
module "lambda_scheduled" {
source = "github.com/terraform-community-modules/tf_aws_lambda_scheduled"
lambda_name = "my_scheduled_lambda"
runtime = "python2.7"
lambda_zipfile = "/valid/path/to/myfunction.zip"
source_code_hash = "${data.archive_file.myfunction.output_base64sha256}"
handler = "myfunction.handler"
schedule_expression = "rate(1 day)"
iam_policy_document = "${data.aws_iam_policy_document.create_snaps.json}"
}
lambda_arn
- ARN for the created Lambda function
Created and maintained by Shayne Clausson