-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiam.tf
81 lines (77 loc) · 2.09 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
data "aws_iam_policy_document" "ecs_read_allow" {
count = var.create_role && local.to_be_reported_ecs ? 1 : 0
statement {
sid = "ECSList"
effect = "Allow"
actions = [
"ecs:ListClusters",
"ecs:ListServices",
"ecs:ListTasks"
]
resources = [
"*"
]
}
statement {
sid = "ECSDescribe"
actions = [
"ecs:DescribeServices",
"ecs:DescribeTasks",
"ecs:DescribeClusters",
]
resources = [
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster/*",
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/*/*",
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task/*",
]
}
}
data "aws_iam_policy_document" "lambda_read_allow" {
count = var.create_role && local.to_be_reported_lambda ? 1 : 0
statement {
sid = "LambdaRead"
effect = "Allow"
actions = [
"lambda:GetFunctionConfiguration",
"lambda:ListFunctions"
]
resources = ["*"]
}
}
data "aws_iam_policy_document" "s3_read_allow" {
count = var.create_role && local.to_be_reported_s3 ? 1 : 0
statement {
sid = "S3Read"
effect = "Allow"
actions = [
"s3:ListBucket",
"S3:GetObject"
]
resources = [
"arn:aws:s3:::*/*",
"arn:aws:s3:::*"
]
}
}
data "aws_iam_policy_document" "ssm_read_allow" {
count = var.create_role ? 1 : 0
statement {
sid = "SSMRead"
effect = "Allow"
actions = [
"ssm:GetParameter"
]
resources = [
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/${var.kosli_api_token_ssm_parameter_name}"
]
}
}
data "aws_iam_policy_document" "combined" {
count = var.create_role ? 1 : 0
source_policy_documents = concat(
data.aws_iam_policy_document.ecs_read_allow.*.json,
data.aws_iam_policy_document.lambda_read_allow.*.json,
data.aws_iam_policy_document.s3_read_allow.*.json,
data.aws_iam_policy_document.ssm_read_allow.*.json
)
}