Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten GSA account_id if necessary #666

Merged
merged 5 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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