Skip to content

Commit

Permalink
fix: Chain GOOGLE_CREDENTIALS variable on kubectl-wrapper submodule (#95
Browse files Browse the repository at this point in the history
)

* Addresses #93

* Correcting docs

Co-authored-by: Morgante Pell <[email protected]>
  • Loading branch information
dansiviter and morgante authored May 25, 2021
1 parent 6037c26 commit 48e1fee
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Setting it to `never` will *never* gcloud download and setting it to `always` wi
| service\_account\_key\_file | Path to service account key file to run `gcloud auth activate-service-account` with. Optional. | `string` | `""` | no |
| skip\_download | Whether to skip downloading gcloud (assumes gcloud is already available outside the module) | `bool` | `true` | no |
| upgrade | Whether to upgrade gcloud at runtime | `bool` | `true` | no |
| use\_tf\_google\_credentials\_env\_var | Use GOOGLE\_CREDENTIALS environment variable to run `gcloud auth activate-service-account` with. Optional. | `bool` | `false` | no |
| use\_tf\_google\_credentials\_env\_var | Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional. | `bool` | `false` | no |

## Outputs

Expand Down
1 change: 1 addition & 0 deletions modules/kubectl-wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module "kubectl" {
| skip\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl is already available outside the module) | `bool` | `true` | no |
| upgrade | Whether to upgrade gcloud at runtime | `bool` | `true` | no |
| use\_existing\_context | Use existing kubecontext to auth kube-api. | `bool` | `false` | no |
| use\_tf\_google\_credentials\_env\_var | Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional. | `bool` | `false` | no |

## Outputs

Expand Down
17 changes: 9 additions & 8 deletions modules/kubectl-wrapper/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ locals {
}

module "gcloud_kubectl" {
source = "../.."
module_depends_on = var.module_depends_on
additional_components = var.additional_components
skip_download = var.skip_download
gcloud_sdk_version = var.gcloud_sdk_version
enabled = var.enabled
upgrade = var.upgrade
service_account_key_file = var.service_account_key_file
source = "../.."
module_depends_on = var.module_depends_on
additional_components = var.additional_components
skip_download = var.skip_download
gcloud_sdk_version = var.gcloud_sdk_version
enabled = var.enabled
upgrade = var.upgrade
service_account_key_file = var.service_account_key_file
use_tf_google_credentials_env_var = var.use_tf_google_credentials_env_var

create_cmd_entrypoint = "${path.module}/scripts/kubectl_wrapper.sh"
create_cmd_body = var.impersonate_service_account == "" ? "${local.base_cmd} ${var.kubectl_create_command}" : "${local.base_cmd} true ${var.impersonate_service_account} ${var.kubectl_create_command}"
Expand Down
5 changes: 5 additions & 0 deletions modules/kubectl-wrapper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ variable "service_account_key_file" {
default = ""
}

variable "use_tf_google_credentials_env_var" {
description = "Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional."
default = false
}

variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ variable "service_account_key_file" {
}

variable "use_tf_google_credentials_env_var" {
description = "Use GOOGLE_CREDENTIALS environment variable to run `gcloud auth activate-service-account` with. Optional."
description = "Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional."
default = false
}

Expand Down

0 comments on commit 48e1fee

Please sign in to comment.