-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
37 lines (30 loc) · 998 Bytes
/
main.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
resource "aws_iam_policy" "irsa" {
name = "${var.cluster_name}-${var.irsa_name}"
description = ""
policy = var.policy_body
}
resource "aws_iam_policy_attachment" "irsa" {
name = "${var.cluster_name}-${var.irsa_name}"
roles = [aws_iam_role.irsa.name]
policy_arn = aws_iam_policy.irsa.arn
}
data "aws_iam_policy_document" "irsa" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringEquals"
variable = "${replace(data.aws_iam_openid_connect_provider.cluster.url, "https://", "")}:sub"
values = ["system:serviceaccount:${var.namespace}:${var.irsa_name}"]
}
principals {
identifiers = [data.aws_iam_openid_connect_provider.cluster.arn]
type = "Federated"
}
}
}
resource "aws_iam_role" "irsa" {
name = "${var.cluster_name}-${var.irsa_name}"
description = ""
assume_role_policy = data.aws_iam_policy_document.irsa.json
}