Skip to content

Commit

Permalink
feat: Add IAM permissions for ELB svc-linked role creation by EKS clu…
Browse files Browse the repository at this point in the history
…ster (#902)

AmazonEKSClusterPolicy IAM policy doesn't contain all necessary permissions to create ELB service-linked role required during LB provisioning at AWS by K8S Service.

terraform-aws-modules/terraform-aws-eks#900
terraform-aws-modules/terraform-aws-eks#183 (comment)
  • Loading branch information
baibailiha authored Dec 28, 2021
1 parent 6b216b1 commit 5b20547
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,28 @@ resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSServicePolicy" {
policy_arn = "${local.policy_arn_prefix}/AmazonEKSServicePolicy"
role = local.cluster_iam_role_name
}

/*
Adding a policy to cluster IAM role that allow permissions
required to create AWSServiceRoleForElasticLoadBalancing service-linked role by EKS during ELB provisioning
*/

data "aws_iam_policy_document" "cluster_elb_sl_role_creation" {
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0

statement {
effect = "Allow"
actions = [
"ec2:DescribeAccountAttributes",
"ec2:DescribeInternetGateways"
]
resources = ["*"]
}
}

resource "aws_iam_role_policy" "cluster_elb_sl_role_creation" {
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
name_prefix = "${var.cluster_name}-elb-sl-role-creation"
role = local.cluster_iam_role_name
policy = data.aws_iam_policy_document.cluster_elb_sl_role_creation[0].json
}

0 comments on commit 5b20547

Please sign in to comment.