forked from binbashar/terraform-aws-certbot-lambda
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloudwatch.tf
More file actions
19 lines (17 loc) · 754 Bytes
/
cloudwatch.tf
File metadata and controls
19 lines (17 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Create a timer that runs every 12 hours
resource "aws_cloudwatch_event_rule" "certbot_lambda_timer" {
name = "${var.name_prefix}-timer-${var.name}"
schedule_expression = "cron(0 */12 * * ? *)"
}
# Specify the lambda function to run
resource "aws_cloudwatch_event_target" "lets_encrypt_timer_target" {
rule = aws_cloudwatch_event_rule.certbot_lambda_timer.name
arn = module.certbot_lambda_jenkins.function_arn
}
# Give cloudwatch permission to invoke the function
resource "aws_lambda_permission" "permission" {
action = "lambda:InvokeFunction"
function_name = module.certbot_lambda_jenkins.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.certbot_lambda_timer.arn
}