Skip to content

Commit

Permalink
Adding extra permissions to the cluster's default service account
Browse files Browse the repository at this point in the history
Signed-off-by: Julliano Goncalves <[email protected]>
  • Loading branch information
jullianow committed May 14, 2024
1 parent dbd90e3 commit ba1bbe8
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autogen/main/sa.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-autopilot-private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-autopilot-public-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-private-cluster-update-variant/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-public-cluster-update-variant/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-public-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/private-cluster-update-variant/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions modules/private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down
14 changes: 14 additions & 0 deletions sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ resource "google_project_iam_member" "cluster_service_account-nodeService_accoun
member = google_service_account.cluster_service_account[0].member
}

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

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
count = var.create_service_account ? 1 : 0
project = google_project_iam_member.cluster_service_account-monitoring_viewer[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
Expand Down

0 comments on commit ba1bbe8

Please sign in to comment.