forked from DNXLabs/terraform-aws-eb-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam-roles.tf
34 lines (29 loc) · 950 Bytes
/
iam-roles.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
32
33
34
data "aws_iam_policy_document" "event" {
count = var.ad_directory_name == "" ? 0 : 1
statement {
effect = "Allow"
actions = ["ssm:StartAutomationExecution"]
resources = ["*"]
}
}
data "aws_iam_policy_document" "event_trust" {
count = var.ad_directory_name == "" ? 0 : 1
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["events.amazonaws.com"]
}
}
}
resource "aws_iam_role" "event" {
count = var.ad_directory_name == "" ? 0 : 1
name_prefix = "eb-automation-${var.environment}-${var.name}-"
assume_role_policy = data.aws_iam_policy_document.event_trust[0].json
}
resource "aws_iam_role_policy" "event" {
count = var.ad_directory_name == "" ? 0 : 1
name_prefix = "eb-automation-${var.environment}-${var.name}-"
policy = data.aws_iam_policy_document.event[0].json
role = aws_iam_role.event[0].name
}