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

Grant storage viewer to created service accounts #229

Closed
c4m4 opened this issue Aug 12, 2019 · 3 comments · Fixed by #236
Closed

Grant storage viewer to created service accounts #229

c4m4 opened this issue Aug 12, 2019 · 3 comments · Fixed by #236
Assignees
Labels
enhancement New feature or request

Comments

@c4m4
Copy link

c4m4 commented Aug 12, 2019

I am creating a testing gke cluster using this module, everything works, but after the cluster is being created, docker fails to pull images from gcr private repository, because the service account created by this modules doesn't has the roles/storage.objectViewer

In the sa.tf I don't see nothing for the needed role:

resource "google_service_account" "cluster_service_account" {
  count        = var.service_account == "create" ? 1 : 0
  project      = var.project_id
  account_id   = "tf-gke-${substr(var.name, 0, min(15, length(var.name)))}-${random_string.cluster_service_account_suffix.result}"
  display_name = "Terraform-managed service account for cluster ${var.name}"
}

resource "google_project_iam_member" "cluster_service_account-log_writer" {
  count   = var.service_account == "create" ? 1 : 0
  project = google_service_account.cluster_service_account[0].project
  role    = "roles/logging.logWriter"
  member  = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-metric_writer" {
  count   = var.service_account == "create" ? 1 : 0
  project = google_project_iam_member.cluster_service_account-log_writer[0].project
  role    = "roles/monitoring.metricWriter"
  member  = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-monitoring_viewer" {
  count   = var.service_account == "create" ? 1 : 0
  project = google_project_iam_member.cluster_service_account-metric_writer[0].project
  role    = "roles/monitoring.viewer"
  member  = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

@morgante
Copy link
Contributor

Correct, this module doesn't include the storage viewer role by default (not all customers use GCR).

We could possibly add a flag to add that role. For now, you can also add it yourself:

resource "google_project_iam_member" "cluster_service_account-gcr" {
  project = var.project
  role    = "roles/storage.objectViewer"
  member  = "serviceAccount:${module.gke.service_account}"
}

@c4m4
Copy link
Author

c4m4 commented Aug 12, 2019

Thanks, that solved the issue, but have an option could be nice :)

@morgante
Copy link
Contributor

morgante commented Aug 12, 2019

Agreed. I suggest we add a boolean variable grant_registry_access to the module. If it is true, then a google_project_iam_member block will be included granting the objectViewer role.

@morgante morgante changed the title service_account = "create" Grant storage viewer to created service accounts Aug 12, 2019
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 16, 2019
 * Added `sa_grant_gcs_access` variable to grant `roles/storage.objectViewer` to created SA
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 16, 2019
 * Added `sa_grant_gcs_access` variable to grant `roles/storage.objectViewer` to created SA
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 16, 2019
 * Added `sa_grant_gcs_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes terraform-google-modules#229)
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 16, 2019
 * Added `sa_grant_gcs_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes terraform-google-modules#229)
@paulpalamarchuk paulpalamarchuk self-assigned this Aug 16, 2019
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 16, 2019
 * Added `grant_registry_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes terraform-google-modules#229)
@aaron-lane aaron-lane added the enhancement New feature or request label Aug 16, 2019
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 19, 2019
 * Added `grant_registry_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes terraform-google-modules#229)
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this issue Aug 20, 2019
 * Added `grant_registry_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes terraform-google-modules#229)
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this issue Jul 15, 2024
 * Added `grant_registry_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes terraform-google-modules#229)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants