Skip to content

Commit 7fd85d9

Browse files
authored
feat: add option to skip sa activation (#139)
1 parent 29d7cf9 commit 7fd85d9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Setting it to `never` will *never* gcloud download and setting it to `always` wi
4242

4343
| Name | Description | Type | Default | Required |
4444
|------|-------------|------|---------|:--------:|
45+
| activate\_service\_account | Set to false to skip running `gcloud auth activate-service-account`. Optional. | `bool` | `true` | no |
4546
| additional\_components | Additional gcloud CLI components to install. Defaults to none. Valid value are components listed in `gcloud components list` | `list(string)` | `[]` | no |
4647
| create\_cmd\_body | On create, the command body you'd like to run with your entrypoint. | `string` | `"info"` | no |
4748
| create\_cmd\_entrypoint | On create, the command entrypoint you'd like to use. Can also be set to a custom script. Module's bin directory will be prepended to path. | `string` | `"gcloud"` | no |

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ locals {
4646
upgrade_command = "${local.gcloud} components update --quiet"
4747
additional_components_command = "${path.module}/scripts/check_components.sh ${local.gcloud} ${local.components}"
4848
gcloud_auth_service_account_key_file_command = "${local.gcloud} auth activate-service-account --key-file ${var.service_account_key_file}"
49+
activate_service_account = var.activate_service_account ? "${local.gcloud} auth activate-service-account --key-file ${local.tmp_credentials_path}" : "true"
4950
gcloud_auth_google_credentials_command = <<-EOT
50-
printf "%s" "$GOOGLE_CREDENTIALS" > ${local.tmp_credentials_path} &&
51-
${local.gcloud} auth activate-service-account --key-file ${local.tmp_credentials_path}
51+
printf "%s" "$GOOGLE_CREDENTIALS" > ${local.tmp_credentials_path} && \
52+
${local.activate_service_account}
5253
EOT
5354

5455
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ variable "use_tf_google_credentials_env_var" {
9292
default = false
9393
}
9494

95+
variable "activate_service_account" {
96+
description = "Set to false to skip running `gcloud auth activate-service-account`. Optional."
97+
type = bool
98+
default = true
99+
}
100+
95101
variable "jq_version" {
96102
description = "The jq version to download."
97103
type = string

0 commit comments

Comments
 (0)