-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtask-role.tf
47 lines (45 loc) · 1.35 KB
/
task-role.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
35
36
37
38
39
40
41
42
43
44
45
46
resource "aws_iam_role" "task" {
name = "${var.task_family}-ecs-task"
assume_role_policy = data.aws_iam_policy_document.principal.json
}
resource "aws_iam_role_policy" "task" {
name = "inline1"
role = aws_iam_role.task.id
policy = data.aws_iam_policy_document.task.json
}
resource "aws_iam_role_policy" "task_inline" {
count = length(var.task_inline_policies)
name = "inline-${var.task_inline_policies[count.index].name}"
role = aws_iam_role.task.id
policy = var.task_inline_policies[count.index].policy
}
resource "aws_iam_role_policies_exclusive" "task_inline" {
role_name = aws_iam_role.task.name
policy_names = concat([aws_iam_role_policy.task.name], aws_iam_role_policy.task_inline.*.name)
}
data "aws_iam_policy_document" "task" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
"logs:DeleteLogStream",
"logs:PutLogEvents",
"logs:PutRetentionPolicy",
]
resources = ["*"]
}
dynamic "statement" {
for_each = var.ecs_execute_command_enabled ? [1] : []
content {
actions = [
"ssmmessages:CreateControlChannel",
"ssmmessages:CreateDataChannel",
"ssmmessages:OpenControlChannel",
"ssmmessages:OpenDataChannel",
]
resources = ["*"]
}
}
}