diff --git a/autogen/main/sa.tf.tmpl b/autogen/main/sa.tf.tmpl index cae74cd59..dbc17213a 100644 --- a/autogen/main/sa.tf.tmpl +++ b/autogen/main/sa.tf.tmpl @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/docs/upgrading_to_v29.0.md b/docs/upgrading_to_v29.0.md new file mode 100644 index 000000000..ba63c0efd --- /dev/null +++ b/docs/upgrading_to_v29.0.md @@ -0,0 +1,8 @@ +# Upgrading to v29.0 +The v29.0 release of *kubernetes-engine* is a backwards incompatible +release. + +### Default cluster service account permissions modified + +When `create_service_account` is `true`, the service account will now be created with `Kubernetes Engine Node Service Account` role instead of `Logs Writer`, `Monitoring Metric Writer`, `Monitoring Viewer` and `Stackdriver Resource Metadata Writer` roles. +This is the Google recommended least privileged role to be used for the service account attached to the GKE Nodes. diff --git a/modules/beta-autopilot-private-cluster/sa.tf b/modules/beta-autopilot-private-cluster/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/beta-autopilot-private-cluster/sa.tf +++ b/modules/beta-autopilot-private-cluster/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/beta-autopilot-public-cluster/sa.tf b/modules/beta-autopilot-public-cluster/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/beta-autopilot-public-cluster/sa.tf +++ b/modules/beta-autopilot-public-cluster/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/beta-private-cluster-update-variant/sa.tf b/modules/beta-private-cluster-update-variant/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/beta-private-cluster-update-variant/sa.tf +++ b/modules/beta-private-cluster-update-variant/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/beta-private-cluster/sa.tf b/modules/beta-private-cluster/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/beta-private-cluster/sa.tf +++ b/modules/beta-private-cluster/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/beta-public-cluster-update-variant/sa.tf b/modules/beta-public-cluster-update-variant/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/beta-public-cluster-update-variant/sa.tf +++ b/modules/beta-public-cluster-update-variant/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/beta-public-cluster/sa.tf b/modules/beta-public-cluster/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/beta-public-cluster/sa.tf +++ b/modules/beta-public-cluster/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/private-cluster-update-variant/sa.tf b/modules/private-cluster-update-variant/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/private-cluster-update-variant/sa.tf +++ b/modules/private-cluster-update-variant/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/modules/private-cluster/sa.tf b/modules/private-cluster/sa.tf index 9a13a2490..a19843e0f 100644 --- a/modules/private-cluster/sa.tf +++ b/modules/private-cluster/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member } diff --git a/sa.tf b/sa.tf index 9a13a2490..a19843e0f 100644 --- a/sa.tf +++ b/sa.tf @@ -45,31 +45,10 @@ resource "google_service_account" "cluster_service_account" { display_name = "Terraform-managed service account for cluster ${var.name}" } -resource "google_project_iam_member" "cluster_service_account-log_writer" { +resource "google_project_iam_member" "cluster_service_account-nodeService_account" { count = var.create_service_account ? 1 : 0 project = google_service_account.cluster_service_account[0].project - role = "roles/logging.logWriter" - 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-monitoring_viewer" { - count = var.create_service_account ? 1 : 0 - project = google_project_iam_member.cluster_service_account-metric_writer[0].project - role = "roles/monitoring.viewer" - 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" + role = "roles/container.nodeServiceAccount" member = google_service_account.cluster_service_account[0].member }