Skip to content

Commit

Permalink
Merge pull request #13 from RADAR-base/aws-profiles-for-eks
Browse files Browse the repository at this point in the history
Allow EKS cluster creation when multiple AWS profile are defined
  • Loading branch information
keyvaann authored Dec 6, 2024
2 parents a2a9da9 + 45e6042 commit 8fd4433
Show file tree
Hide file tree
Showing 4 changed files with 18 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"
}
}
8 changes: 8 additions & 0 deletions cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ variable "AWS_REGION" {
variable "AWS_ACCESS_KEY_ID" {
type = string
description = "AWS access key associated with an IAM account"
default = ""
sensitive = true
}

variable "AWS_SECRET_ACCESS_KEY" {
type = string
description = "AWS secret key associated with the access key"
default = ""
sensitive = true
}

Expand All @@ -23,6 +25,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 8fd4433

Please sign in to comment.