Skip to content

Commit

Permalink
Fix #288: not able to use AWS Profiles (#310)
Browse files Browse the repository at this point in the history
* added conditional profile

* Add profile variable

* Added profile flag

* Spelling is hard

* removed default to allow ENV override

* add conditional check

* default to null so we can see if it's been set

* Added profile variable to module
  • Loading branch information
mrmarcsmith authored Sep 21, 2021
1 parent b27a316 commit e5d3da2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ We use GitHub issues to track public bugs. Report a bug by opening a new issue h
## Run make test to test your infrastructure after running Terraform

```shell
$ make lint # runs the linter
$ make test # runs terratest tests against your currently connected AWS account.
```

Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module "cluster" {
tls_cert = var.tls_cert
tls_key = var.tls_key
local-exec-interpreter = var.local-exec-interpreter
profile = var.profile
}

// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion modules/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ resource "null_resource" "kubeconfig" {
module.eks
]
provisioner "local-exec" {
command = "aws eks update-kubeconfig --name ${var.cluster_name} --region=${var.region}"
command = "aws eks update-kubeconfig --name ${var.cluster_name} --region=${var.region} ${var.profile == null ? "" : format("--profile=%s", var.profile)}"
interpreter = var.local-exec-interpreter
}
}
Expand Down
6 changes: 6 additions & 0 deletions modules/cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "cluster_version" {
type = string
}

variable "profile" {
description = "The AWS Profile used to provision the EKS Cluster"
type = string
default = null
}

# Worker Nodes
variable "desired_node_count" {
type = number
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "cluster_name" {
default = ""
}

variable "profile" {
description = "The AWS Profile used to provision the EKS Cluster"
type = string
default = null
}

variable "cluster_version" {
description = "Kubernetes version to use for the EKS cluster."
type = string
Expand Down

0 comments on commit e5d3da2

Please sign in to comment.