Skip to content

Commit

Permalink
fix: Use role_name to create access entry
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyovriakh committed Feb 14, 2024
1 parent bbd4089 commit 9b14257
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions modules/services/eks/datasources.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
data "aws_caller_identity" "current" {}

data "aws_eks_clusters" "clusters" {}

data "aws_eks_cluster" "clusters" {
Expand Down
3 changes: 3 additions & 0 deletions modules/services/eks/locals.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
locals {
account_id = data.aws_caller_identity.current.account_id
principal_arn = "arn:aws:iam::${local.account_id}:role/${var.role_name}"

api_enabled_clusters = [
for cluster in data.aws_eks_cluster.clusters :
cluster if contains(["API", "API_AND_CONFIG_MAP"], cluster.access_config[0].authentication_mode)
Expand Down
2 changes: 1 addition & 1 deletion modules/services/eks/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "awscc_eks_access_entry" "viewer" {
for_each = local.clusters
cluster_name = each.value.name
principal_arn = var.principal_arn // TODO: Use data source
principal_arn = local.principal_arn // TODO: Use data source
access_policies = [local.cluster_access_policy]
}
4 changes: 2 additions & 2 deletions modules/services/eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variable "clusters" {
default = []
}

variable "principal_arn" {
description = "Sysdig's IAM Principal ARN which will access the EKS clusters"
variable "role_name" {
description = "IAM role that Sysdig will assume to access the EKS clusters"
type = string
}

0 comments on commit 9b14257

Please sign in to comment.