Skip to content

Commit 4374b10

Browse files
committed
Enhance EKS addons module: add cluster OIDC provider ARN variable and update IAM role assumption
1 parent afa4e84 commit 4374b10

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

deployments/stacks/dpe-k8s-deployments/main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ module "sage-aws-eks-autoscaler" {
1313
}
1414

1515
module "sage-aws-eks-addons" {
16-
source = "../../../modules/sage-aws-eks-addons"
17-
cluster_name = var.cluster_name
18-
aws_account_id = var.aws_account_id
19-
vpc_id = var.vpc_id
20-
private_subnet_ids = var.private_subnet_ids_eks_worker_nodes
16+
source = "../../../modules/sage-aws-eks-addons"
17+
cluster_name = var.cluster_name
18+
aws_account_id = var.aws_account_id
19+
vpc_id = var.vpc_id
20+
private_subnet_ids = var.private_subnet_ids_eks_worker_nodes
21+
cluster_oidc_provider_arn = var.cluster_oidc_provider_arn
2122
}
2223

2324
module "argo-cd" {

modules/sage-aws-eks-addons/data.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,3 @@ data "aws_iam_policy_document" "restrict-vpc-endpoint-usage" {
3131
data "aws_eks_cluster" "cluster" {
3232
name = var.cluster_name
3333
}
34-
35-
data "aws_iam_openid_connect_provider" "eks" {
36-
url = data.aws_eks_cluster.cluster.identity[0].oidc[0].issuer
37-
}

modules/sage-aws-eks-addons/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ resource "aws_iam_role" "guardduty_agent_role" {
9393
Action = "sts:AssumeRoleWithWebIdentity"
9494
Effect = "Allow"
9595
Principal = {
96-
Federated = data.aws_iam_openid_connect_provider.eks.arn
96+
Federated = var.cluster_oidc_provider_arn
9797
}
9898
Condition = {
9999
StringEquals = {

modules/sage-aws-eks-addons/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "vpc_id" {
2222
type = string
2323
}
2424

25+
variable "cluster_oidc_provider_arn" {
26+
description = "EKS cluster ARN for the OIDC provider"
27+
type = string
28+
}
29+
2530
variable "private_subnet_ids" {
2631
description = "Private subnet IDs"
2732
type = list(string)

0 commit comments

Comments
 (0)