Skip to content

Commit c97d4e6

Browse files
committed
Use elbv2 tag condition for all elasticloadbalancing actions
1 parent d40cb29 commit c97d4e6

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

pkg/model/iam/iam_builder.go

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,28 +1001,41 @@ func AddAWSLoadbalancerControllerPermissions(p *Policy, enableWAF, enableWAFv2,
10011001
"ec2:AuthorizeSecurityGroupIngress", // aws.go
10021002
"ec2:DeleteSecurityGroup", // aws.go
10031003
"ec2:RevokeSecurityGroupIngress", // aws.go
1004-
1005-
"elasticloadbalancing:AddListenerCertificates",
1006-
"elasticloadbalancing:AddTags",
1007-
"elasticloadbalancing:DeleteListener",
1008-
"elasticloadbalancing:DeleteLoadBalancer",
1009-
"elasticloadbalancing:DeleteRule",
1010-
"elasticloadbalancing:DeleteTargetGroup",
1011-
"elasticloadbalancing:DeregisterTargets",
1012-
"elasticloadbalancing:ModifyCapacityReservation",
1013-
"elasticloadbalancing:ModifyListener",
1014-
"elasticloadbalancing:ModifyListenerAttributes",
1015-
"elasticloadbalancing:ModifyLoadBalancerAttributes",
1016-
"elasticloadbalancing:ModifyRule",
1017-
"elasticloadbalancing:ModifyTargetGroup",
1018-
"elasticloadbalancing:ModifyTargetGroupAttributes",
1019-
"elasticloadbalancing:RegisterTargets",
1020-
"elasticloadbalancing:RemoveListenerCertificates",
1021-
"elasticloadbalancing:RemoveTags",
1022-
"elasticloadbalancing:SetIpAddressType",
1023-
"elasticloadbalancing:SetSecurityGroups",
1024-
"elasticloadbalancing:SetSubnets",
10251004
)
1005+
// ELBv2 management actions: resources are tagged with elbv2.k8s.aws/cluster
1006+
// by the LBC tracking provider, not KubernetesCluster, so clusterTaggedAction
1007+
// (which uses aws:ResourceTag/KubernetesCluster) cannot be used here.
1008+
p.Statement = append(p.Statement, &Statement{
1009+
Effect: StatementEffectAllow,
1010+
Action: stringorset.Of(
1011+
"elasticloadbalancing:AddListenerCertificates",
1012+
"elasticloadbalancing:AddTags",
1013+
"elasticloadbalancing:DeleteListener",
1014+
"elasticloadbalancing:DeleteLoadBalancer",
1015+
"elasticloadbalancing:DeleteRule",
1016+
"elasticloadbalancing:DeleteTargetGroup",
1017+
"elasticloadbalancing:DeregisterTargets",
1018+
"elasticloadbalancing:ModifyCapacityReservation",
1019+
"elasticloadbalancing:ModifyListener",
1020+
"elasticloadbalancing:ModifyListenerAttributes",
1021+
"elasticloadbalancing:ModifyLoadBalancerAttributes",
1022+
"elasticloadbalancing:ModifyRule",
1023+
"elasticloadbalancing:ModifyTargetGroup",
1024+
"elasticloadbalancing:ModifyTargetGroupAttributes",
1025+
"elasticloadbalancing:RegisterTargets",
1026+
"elasticloadbalancing:RemoveListenerCertificates",
1027+
"elasticloadbalancing:RemoveTags",
1028+
"elasticloadbalancing:SetIpAddressType",
1029+
"elasticloadbalancing:SetSecurityGroups",
1030+
"elasticloadbalancing:SetSubnets",
1031+
),
1032+
Resource: stringorset.String("*"),
1033+
Condition: Condition{
1034+
"StringEquals": map[string]string{
1035+
"aws:ResourceTag/elbv2.k8s.aws/cluster": p.clusterName,
1036+
},
1037+
},
1038+
})
10261039
// LBC only includes the elbv2.k8s.aws/cluster tag in the create request.
10271040
// KubernetesCluster and other tags are applied separately via AddTags,
10281041
// So aws:RequestTag must reference the elbv2.k8s.aws/cluster tag.

0 commit comments

Comments
 (0)