-
Notifications
You must be signed in to change notification settings - Fork 45
/
iam_chart_museum.tf
62 lines (47 loc) · 1.37 KB
/
iam_chart_museum.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
data "aws_iam_policy_document" "chartmuseum_assume_role" {
count = var.enable_chart_museum ? 1 : 0
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
principals {
identifiers = [aws_iam_openid_connect_provider.eks.arn]
type = "Federated"
}
}
}
resource "aws_iam_role" "chartmuseum" {
count = var.enable_chart_museum ? 1 : 0
assume_role_policy = data.aws_iam_policy_document.chartmuseum_assume_role[count.index].json
name = format("%s-chartmuseum", var.cluster_name)
}
data "aws_iam_policy_document" "chartmuseum" {
count = var.enable_chart_museum ? 1 : 0
version = "2012-10-17"
statement {
effect = "Allow"
actions = [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket"
]
resources = [
"*"
]
}
}
resource "aws_iam_policy" "chartmuseum" {
count = var.enable_chart_museum ? 1 : 0
name = format("%s-chartmuseum-policy", var.cluster_name)
path = "/"
description = var.cluster_name
policy = data.aws_iam_policy_document.chartmuseum[count.index].json
}
resource "aws_iam_policy_attachment" "chartmuseum" {
count = var.enable_chart_museum ? 1 : 0
name = "cluster_autoscaler"
roles = [
aws_iam_role.chartmuseum[count.index].name
]
policy_arn = aws_iam_policy.chartmuseum[count.index].arn
}