-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathiam.tf
58 lines (42 loc) · 1.13 KB
/
iam.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
47
48
49
50
51
52
53
54
55
56
57
58
locals {
iam_role_enabled = local.enabled && var.iam_role_enabled
}
module "role" {
source = "cloudposse/iam-role/aws"
version = "0.16.2"
enabled = local.iam_role_enabled
attributes = compact(concat(module.this.attributes, ["log", "group"]))
role_description = "Cloudwatch ${module.this.id} logs role"
policy_description = "Cloudwatch ${module.this.id} logs policy"
principals = var.principals
policy_documents = [
join("", data.aws_iam_policy_document.log_agent.*.json),
]
permissions_boundary = var.permissions_boundary
tags_enabled = var.iam_tags_enabled
context = module.this.context
}
data "aws_iam_policy_document" "log_agent" {
count = local.iam_role_enabled ? 1 : 0
statement {
actions = [
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
]
resources = ["*"]
}
statement {
actions = [
"logs:PutLogEvents",
]
resources = [
join("", aws_cloudwatch_log_group.default.*.arn),
]
}
statement {
actions = var.additional_permissions
resources = [
"${join("", aws_cloudwatch_log_group.default.*.arn)}:*",
]
}
}