forked from bridgecrewio/terraform-aws-bridgecrew-cloudtrail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam_bridgecrew_cws_policy.tf
88 lines (72 loc) · 1.81 KB
/
iam_bridgecrew_cws_policy.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
resource "aws_iam_policy" "bridgecrew_cws_policy" {
count = var.create_bridgecrew_connection ? 1 : 0
name = "bridgecrew_cws_policy"
policy = data.aws_iam_policy_document.bridgecrew_cws_policy[0].json
}
data "aws_iam_policy_document" "bridgecrew_cws_policy" {
count = var.create_bridgecrew_connection ? 1 : 0
statement {
sid = "ConsumeNotifications"
actions = [
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl",
"sqs:DeleteMessage",
"sqs:ReceiveMessage",
]
effect = "Allow"
resources = [aws_sqs_queue.cloudtrail_queue[0].arn]
}
statement {
sid = "ListLogFiles"
actions = [
"s3:ListBucket",
]
effect = "Allow"
resources = ["arn:aws:s3:::${local.s3_bucket}/AWSLogs/*"]
condition {
test = "StringLike"
variable = "s3:prefix"
values = ["AWSLogs/*"]
}
}
statement {
sid = "ReadLogFiles"
actions = [
"s3:Get*",
]
effect = "Allow"
resources = ["arn:aws:s3:::${local.s3_bucket}/AWSLogs/*"]
}
statement {
sid = "GetAccountAlias"
actions = [
"iam:ListAccountAliases",
]
effect = "Allow"
resources = ["*"]
}
dynamic "statement" {
for_each = var.debug_policy ? ["Debug"] : []
content {
sid = each.value
actions = [
"cloudtrail:DescribeTrails",
"cloudtrail:GetTrailTopics",
"cloudtrail:GetTrailStatus",
"cloudtrail:ListPublicKeys",
"s3:GetBucketAcl",
"s3:GetBucketPolicy",
"s3:ListAllMyBuckets",
"s3:GetBucketLocation",
"s3:GetBucketLogging",
"sns:GetSubscriptionAttributes",
"sns:GetTopicAttributes",
"sns:ListSubscriptions",
"sns:ListSubscriptionsByTopic",
"sns:ListTopics"
]
effect = "Allow"
resources = ["*"]
}
}
}