provider "aws" {
region = "${var.aws_region}"
profile = "${var.aws_profile}"
}
resource "aws_cloudwatch_event_rule" "on-rule" {
name = "start-${var.hostname}"
description = "start aws-mtl-jenkins every weekday at 7 am pacific time"
schedule_expression = "cron(00 14 ? * MON-FRI *)"
is_enabled = true
}
resource "aws_cloudwatch_event_target" "start-instances" {
target_id = "AWS-StartEC2Instance"
arn = "arn:aws:ssm:${var.aws_region}::automation-execution/AWS-StartEC2Instance"
role_arn = "arn:aws:iam::213479268921:role/EC2-Stop-Reboot-Instances"
run_command_targets {
key = "InstanceIds"
values = ["i-036349d05f15d81ce"]
}
}