-
Notifications
You must be signed in to change notification settings - Fork 0
/
eks-elb.tf
51 lines (42 loc) · 1.54 KB
/
eks-elb.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
resource "aws_iam_policy" "aws-load-balancer-controller-policy" {
name = "${var.resource_prefix}-aws-load-balancer-controller-policy"
description = "EKS ELB controller policy for the aws-load-balancer-controller SA"
policy = file("iam-policies/eks-aws-load-balancer-controller-policy.json")
tags = {
Origin = var.common_origin_tag
ResourcePrefix = var.resource_prefix
Owner = var.common_owner_tag
Purpose = var.common_purpose_tag
Stack = var.common_stack_tag
}
}
resource "aws_iam_role" "aws-load-balancer-controller-role" {
name = "${var.resource_prefix}-load-balancer-controller-role"
description = "IAM role for the aws-load-balancer-controller SA in EKS"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRoleWithWebIdentity",
Effect = "Allow"
Principal = {
Federated = module.eks.oidc_provider_arn
},
Condition = {
StringEquals = {
"${module.eks.oidc_provider}:aud" : "sts.amazonaws.com"
"${module.eks.oidc_provider}:sub" : "system:serviceaccount:kube-system:aws-load-balancer-controller"
}
}
},
]
})
managed_policy_arns = [aws_iam_policy.aws-load-balancer-controller-policy.arn]
tags = {
Origin = var.common_origin_tag
ResourcePrefix = var.resource_prefix
Owner = var.common_owner_tag
Purpose = var.common_purpose_tag
Stack = var.common_stack_tag
}
}