Skip to content

Commit

Permalink
fix: Shorten GSA account_id if necessary (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Ferriero committed Sep 12, 2020
1 parent c6aea6b commit 0225458
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 56 deletions.
2 changes: 1 addition & 1 deletion modules/workload-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module "my-app-workload-identity" {
| cluster\_name | Cluster name. Required if using existing KSA. | string | `""` | no |
| k8s\_sa\_name | Name for the existing Kubernetes service account | string | `"null"` | no |
| location | Cluster location (region if regional cluster, zone if zonal cluster). Required if using existing KSA. | string | `""` | no |
| name | Name for both service accounts | string | n/a | yes |
| name | Name for both service accounts. The GCP SA will be truncated to the first 30 chars if necessary. | string | n/a | yes |
| namespace | Namespace for k8s service account | string | `"default"` | no |
| project\_id | GCP project ID | string | n/a | yes |
| use\_existing\_k8s\_sa | Use an existing kubernetes service account instead of creating one | bool | `"false"` | no |
Expand Down
4 changes: 3 additions & 1 deletion modules/workload-identity/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ locals {
}

resource "google_service_account" "cluster_service_account" {
account_id = var.name
# GCP service account ids must be < 30 chars matching regex ^[a-z](?:[-a-z0-9]{4,28}[a-z0-9])$
# KSA do not have this naming restriction.
account_id = substr(var.name, 0, 30)
display_name = substr("GCP SA bound to K8S SA ${local.k8s_given_name}", 0, 100)
project = var.project_id
}
Expand Down
53 changes: 0 additions & 53 deletions modules/workload-identity/scripts/kubectl_wrapper.sh

This file was deleted.

2 changes: 1 addition & 1 deletion modules/workload-identity/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

variable "name" {
description = "Name for both service accounts"
description = "Name for both service accounts. The GCP SA will be truncated to the first 30 chars if necessary."
type = string
}

Expand Down

0 comments on commit 0225458

Please sign in to comment.