forked from DNXLabs/terraform-aws-eb-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.tf
31 lines (27 loc) · 925 Bytes
/
events.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
resource "aws_cloudwatch_event_rule" "automation" {
count = var.ad_directory_name == "" ? 0 : 1
name = "eb-automation-${var.environment}-${var.name}"
description = "EB instance join a domain"
event_pattern = <<PATTERN
{
"source": [
"aws.autoscaling"
],
"detail-type": [
"EC2 Instance Launch Successful"
],
"detail": {
"AutoScalingGroupName": [
"${aws_elastic_beanstalk_environment.env.autoscaling_groups[0]}"
]
}
}
PATTERN
}
resource "aws_cloudwatch_event_target" "automation" {
count = var.ad_directory_name == "" ? 0 : 1
arn = "arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:automation-definition/${aws_ssm_document.automation[0].name}:$DEFAULT"
role_arn = aws_iam_role.event[0].arn
rule = aws_cloudwatch_event_rule.automation[0].name
target_id = "eb-automation-${var.environment}-${var.name}"
}