From b4939d8900cef9212e478ef36377d4a429a22c95 Mon Sep 17 00:00:00 2001 From: Keyvan Date: Wed, 4 Dec 2024 21:10:55 +0100 Subject: [PATCH] Allow EKS cluster creation when multiple AWS profile are defined --- cluster/provider.tf | 5 +++-- cluster/variables.tf | 6 ++++++ config/provider.tf | 1 + config/variables.tf | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cluster/provider.tf b/cluster/provider.tf index d554674..485fb0b 100644 --- a/cluster/provider.tf +++ b/cluster/provider.tf @@ -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" { @@ -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" } } @@ -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" } } \ No newline at end of file diff --git a/cluster/variables.tf b/cluster/variables.tf index 7d710f4..adc0b41 100644 --- a/cluster/variables.tf +++ b/cluster/variables.tf @@ -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" diff --git a/config/provider.tf b/config/provider.tf index 53dd645..43bf4eb 100644 --- a/config/provider.tf +++ b/config/provider.tf @@ -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" { diff --git a/config/variables.tf b/config/variables.tf index 707066c..857764f 100644 --- a/config/variables.tf +++ b/config/variables.tf @@ -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"