Skip to content

Commit 6effc48

Browse files
committed
enhancing event role
1 parent 730a3c4 commit 6effc48

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

cloudwatch_event.tf

Lines changed: 0 additions & 25 deletions
This file was deleted.

locals.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
locals {
2+
shared_tags = tomap(
3+
{
4+
"Name" = "${var.teamid}-${var.prjid}",
5+
"team" = var.teamid,
6+
"project" = var.prjid
7+
}
8+
)
9+
}

main.tf

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
locals {
2-
shared_tags = tomap(
3-
{
4-
"Name" = "${var.teamid}-${var.prjid}",
5-
"team" = var.teamid,
6-
"project" = var.prjid
7-
}
8-
)
2+
default_input = { "sourceVersion" = var.branch, "timeoutInMinutesOverride" = var.timeout }
3+
event_input = var.custom_input == null ? local.default_input : var.custom_input
4+
}
5+
6+
resource "aws_cloudwatch_event_rule" "event_rule" {
7+
count = var.deploy_event_rule ? 1 : 0
8+
9+
name = var.name != null ? var.name : "${var.teamid}-${var.prjid}"
10+
description = var.description == null ? "Terraform managed: ${var.teamid}-${var.prjid}" : var.description
11+
schedule_expression = var.schedule
12+
role_arn = var.service_role
13+
14+
tags = merge(local.shared_tags)
15+
}
16+
17+
resource "aws_cloudwatch_event_target" "event_target_input_type" {
18+
count = var.deploy_event_target ? 1 : 0
19+
20+
target_id = var.name != null ? var.name : "${var.teamid}-${var.prjid}"
21+
rule = aws_cloudwatch_event_rule.event_rule.*.id[count.index]
22+
arn = var.target_arn
23+
role_arn = var.service_role
24+
input = jsonencode(local.event_input)
925
}

0 commit comments

Comments
 (0)