Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
Created April 15, 2020 06:36
Show Gist options
  • Save wshihadeh/56c18df2c9befb43059080c00562c9f4 to your computer and use it in GitHub Desktop.
Save wshihadeh/56c18df2c9befb43059080c00562c9f4 to your computer and use it in GitHub Desktop.
aws_cloudwatch_event_rule
resource "aws_cloudwatch_event_rule" "ec2_stop_rule" {
name = "StopEC2Instances"
description = "Stop EC2 nodes at 19:00 from Monday to friday"
schedule_expression = "cron(0 19 ? * 2-6 *)"
}
resource "aws_cloudwatch_event_target" "ec2_stop_rule_target" {
rule = "${aws_cloudwatch_event_rule.ec2_stop_rule.name}"
arn = "${aws_lambda_function.stop_ec2_lambda.arn}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment