-
Notifications
You must be signed in to change notification settings - Fork 1
/
iam.tf
52 lines (47 loc) · 1.27 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
data "aws_iam_policy_document" "policy" {
statement {
sid = ""
effect = "Allow"
resources = ["arn:aws:route53:::hostedzone/*"]
actions = ["route53:ChangeResourceRecordSets"]
}
statement {
sid = ""
effect = "Allow"
resources = ["*"]
actions = [
"route53:ListHostedZones",
"route53:ListResourceRecordSets",
]
}
}
resource "aws_iam_policy" "external-dns-iam-policy" {
name = "EksExternalDnsIAMPolicy"
policy = data.aws_iam_policy_document.policy.json
}
resource "aws_iam_role" "external-dns-iam-role" {
name = "EksExternalDnsIAMRole"
assume_role_policy = jsonencode(
{
Statement = [
{
Action = "sts:AssumeRoleWithWebIdentity"
Condition = {
StringEquals = {
"${var.oidc_host_path}:aud" = "sts.amazonaws.com"
}
}
Effect = "Allow",
Principal = {
Federated = "arn:aws:iam::${var.account_id}:oidc-provider/${var.oidc_host_path}"
}
},
]
Version = "2012-10-17"
}
)
}
resource "aws_iam_role_policy_attachment" "external-dns-iam-role-policy-attachment" {
role = aws_iam_role.external-dns-iam-role.name
policy_arn = aws_iam_policy.external-dns-iam-policy.arn
}