Skip to content

Commit

Permalink
Reduce permissions on gke-node service account.
Browse files Browse the repository at this point in the history
* monitoring.viewer is already covered by monitoring.metricWriter
* stackdriver.resourceMetadata.writer is unused

Tested on robco-ensonic gcp project.
  • Loading branch information
ensonic committed Nov 14, 2023
1 parent bb299c0 commit 40217c9
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions src/bootstrap/cloud/terraform/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,17 @@ resource "google_service_account" "gke_node" {
display_name = "gke-node"
}

resource "google_project_iam_member" "gke_node_monitoring_viewer" {
resource "google_project_iam_member" "gke_node_roles" {
project = data.google_project.project.project_id
role = "roles/monitoring.viewer"
member = "serviceAccount:${google_service_account.gke_node.email}"
}

resource "google_project_iam_member" "gke_node_monitoring_metricWriter" {
project = data.google_project.project.project_id
role = "roles/monitoring.metricWriter"
member = "serviceAccount:${google_service_account.gke_node.email}"
}

resource "google_project_iam_member" "gke_node_logging_logWriter" {
project = data.google_project.project.project_id
role = "roles/logging.logWriter"
member = "serviceAccount:${google_service_account.gke_node.email}"
}

resource "google_project_iam_member" "gke_node_stackdriver_writer" {
project = data.google_project.project.project_id
role = "roles/stackdriver.resourceMetadata.writer"
member = "serviceAccount:${google_service_account.gke_node.email}"
}

resource "google_project_iam_member" "gke_node_storage_objectViewer" {
project = data.google_project.project.project_id
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.gke_node.email}"
for_each = toset([
# fluentbit/fluentd
"roles/logging.logWriter",
# TODO: document usage
"roles/monitoring.metricWriter",
"roles/storage.objectViewer",
])
role = each.key
}

# This binding allows access to private container registries.
Expand Down

0 comments on commit 40217c9

Please sign in to comment.