Skip to content

Commit

Permalink
Allow EKS cluster creation when multiple AWS profile are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
keyvaann committed Dec 4, 2024
1 parent f31d567 commit b4939d8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cluster/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ provider "aws" {
access_key = var.AWS_ACCESS_KEY_ID
secret_key = var.AWS_SECRET_ACCESS_KEY
token = var.AWS_SESSION_TOKEN
profile = var.AWS_PROFILE
}

provider "kubernetes" {
Expand All @@ -11,7 +12,7 @@ provider "kubernetes" {

exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--region", var.AWS_REGION]
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--region", var.AWS_REGION, "--profile", var.AWS_PROFILE]
command = "aws"
}
}
Expand All @@ -24,7 +25,7 @@ provider "kubectl" {

exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--region", var.AWS_REGION]
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--region", var.AWS_REGION, "--profile", var.AWS_PROFILE]
command = "aws"
}
}
6 changes: 6 additions & 0 deletions cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ variable "AWS_SESSION_TOKEN" {
sensitive = true
}

variable "AWS_PROFILE" {
type = string
description = "AWS Profile that resources are created in"
default = "default"
}

variable "eks_cluster_name" {
type = string
description = "EKS cluster name"
Expand Down
1 change: 1 addition & 0 deletions config/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ provider "aws" {
access_key = var.AWS_ACCESS_KEY_ID
secret_key = var.AWS_SECRET_ACCESS_KEY
token = var.AWS_SESSION_TOKEN
profile = var.AWS_PROFILE
}

provider "kubernetes" {
Expand Down
6 changes: 6 additions & 0 deletions config/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ variable "AWS_SESSION_TOKEN" {
sensitive = true
}

variable "AWS_PROFILE" {
type = string
description = "AWS Profile that resources are created in"
default = "default"
}

variable "eks_cluster_name" {
type = string
description = "EKS cluster name"
Expand Down

0 comments on commit b4939d8

Please sign in to comment.