Skip to content

Commit 3f2cdc8

Browse files
authored
feat: Add eks:DescribeCluster for Karpenter cluster endpoint auto discovery (#343)
1 parent ab21f0a commit 3f2cdc8

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

modules/iam-role-for-service-accounts-eks/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ No modules.
170170
| [aws_iam_policy_document.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
171171
| [aws_iam_policy_document.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
172172
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
173+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
173174

174175
## Inputs
175176

modules/iam-role-for-service-accounts-eks/main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
data "aws_partition" "current" {}
22
data "aws_caller_identity" "current" {}
3+
data "aws_region" "current" {}
34

45
locals {
56
account_id = data.aws_caller_identity.current.account_id
67
partition = data.aws_partition.current.partition
78
dns_suffix = data.aws_partition.current.dns_suffix
9+
region = data.aws_region.current.name
810
role_name_condition = var.role_name != null ? var.role_name : "${var.role_name_prefix}*"
911
}
1012

modules/iam-role-for-service-accounts-eks/policies.tf

+5
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,11 @@ data "aws_iam_policy_document" "karpenter_controller" {
599599
resources = var.karpenter_controller_node_iam_role_arns
600600
}
601601

602+
statement {
603+
actions = ["eks:DescribeCluster"]
604+
resources = ["arn:${local.partition}:eks:${local.region}:${local.account_id}:cluster/${var.karpenter_controller_cluster_id}"]
605+
}
606+
602607
dynamic "statement" {
603608
for_each = var.karpenter_sqs_queue_arn != null ? [1] : []
604609

0 commit comments

Comments
 (0)