Skip to content

Commit ff271a9

Browse files
expose service account variable for ACM module (#667)
1 parent 182dded commit ff271a9

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

modules/acm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ By default, this module will attempt to download the ACM operator from Google di
5656
| policy\_dir | Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default. | string | `""` | no |
5757
| project\_id | GCP project_id used to reach cluster. | string | n/a | yes |
5858
| secret\_type | git authentication secret type, is passed through to ConfigManagement spec.git.secretType. Overriden to value 'ssh' if `create_ssh_key` is true | string | `"ssh"` | no |
59+
| service\_account\_key\_file | Path to service account key file to auth as for running `gcloud container clusters get-credentials`. | string | `""` | no |
5960
| skip\_gcloud\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl already available outside the module) | bool | `"true"` | no |
6061
| source\_format | Configures a non-hierarchical repo if set to 'unstructured'. Uses [ACM defaults](https://cloud.google.com/anthos-config-management/docs/how-to/installing#configuring-config-management-operator) when unset. | string | `""` | no |
6162
| ssh\_auth\_key | Key for Git authentication. Overrides 'create_ssh_key' variable. Can be set using 'file(path/to/file)'-function. | string | `"null"` | no |

modules/acm/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module "acm_operator" {
3535
source_format = var.source_format
3636
hierarchy_controller = var.hierarchy_controller
3737
enable_log_denies = var.enable_log_denies
38+
service_account_key_file = var.service_account_key_file
3839

3940
operator_latest_manifest_url = "gs://config-management-release/released/latest/config-management-operator.yaml"
4041
operator_cr_template_path = "${path.module}/templates/acm-config.yml.tpl"

modules/acm/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ variable "enable_log_denies" {
110110
type = bool
111111
default = false
112112
}
113+
114+
variable "service_account_key_file" {
115+
description = "Path to service account key file to auth as for running `gcloud container clusters get-credentials`."
116+
default = ""
117+
}

modules/k8s-operator-crd-support/main.tf

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ module "k8sop_manifest" {
4040

4141

4242
module "k8s_operator" {
43-
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
44-
version = "~> 2.0.2"
45-
module_depends_on = [module.k8sop_manifest.wait, var.cluster_endpoint]
46-
skip_download = var.skip_gcloud_download
47-
cluster_name = var.cluster_name
48-
cluster_location = var.location
49-
project_id = var.project_id
43+
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
44+
version = "~> 2.0.2"
45+
module_depends_on = [module.k8sop_manifest.wait, var.cluster_endpoint]
46+
skip_download = var.skip_gcloud_download
47+
cluster_name = var.cluster_name
48+
cluster_location = var.location
49+
project_id = var.project_id
50+
service_account_key_file = var.service_account_key_file
5051

5152
kubectl_create_command = "kubectl apply -f ${local.manifest_path}"
5253
kubectl_destroy_command = "kubectl delete -f ${local.manifest_path}"
@@ -60,13 +61,14 @@ resource "tls_private_key" "k8sop_creds" {
6061
}
6162

6263
module "k8sop_creds_secret" {
63-
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
64-
version = "~> 2.0.2"
65-
module_depends_on = [module.k8s_operator.wait]
66-
skip_download = var.skip_gcloud_download
67-
cluster_name = var.cluster_name
68-
cluster_location = var.location
69-
project_id = var.project_id
64+
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
65+
version = "~> 2.0.2"
66+
module_depends_on = [module.k8s_operator.wait]
67+
skip_download = var.skip_gcloud_download
68+
cluster_name = var.cluster_name
69+
cluster_location = var.location
70+
project_id = var.project_id
71+
service_account_key_file = var.service_account_key_file
7072

7173
kubectl_create_command = "kubectl create secret generic ${var.operator_credential_name} -n=${var.operator_credential_namespace} --from-literal=${local.k8sop_creds_secret_key}='${local.private_key}'"
7274
kubectl_destroy_command = "kubectl delete secret ${var.operator_credential_name} -n=${var.operator_credential_namespace}"
@@ -96,14 +98,15 @@ resource "local_file" "operator_cr" {
9698
}
9799

98100
module "k8sop_config" {
99-
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
100-
version = "~> 2.0.2"
101-
module_depends_on = [module.k8s_operator.wait, module.k8sop_creds_secret.wait]
102-
skip_download = var.skip_gcloud_download
103-
cluster_name = var.cluster_name
104-
cluster_location = var.location
105-
project_id = var.project_id
106-
create_cmd_triggers = { configmanagement = local_file.operator_cr.content }
101+
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
102+
version = "~> 2.0.2"
103+
module_depends_on = [module.k8s_operator.wait, module.k8sop_creds_secret.wait]
104+
skip_download = var.skip_gcloud_download
105+
cluster_name = var.cluster_name
106+
cluster_location = var.location
107+
project_id = var.project_id
108+
create_cmd_triggers = { configmanagement = local_file.operator_cr.content }
109+
service_account_key_file = var.service_account_key_file
107110

108111
kubectl_create_command = "kubectl apply -f ${local_file.operator_cr.filename}"
109112
kubectl_destroy_command = "kubectl delete -f ${local_file.operator_cr.filename}"

modules/k8s-operator-crd-support/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ variable "enable_log_denies" {
134134
type = bool
135135
default = false
136136
}
137+
138+
variable "service_account_key_file" {
139+
description = "Path to service account key file to auth as for running `gcloud container clusters get-credentials`."
140+
default = ""
141+
}

0 commit comments

Comments
 (0)