Add OS login admin permissions for Compute Engine Service Agent

Use this example to add OS Login admin role to the Compute Engine service account.

Code sample

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

data "google_project" "project" {
}
resource "google_project_iam_member" "os_login_admin_users" {
  project = data.google_project.project.project_id
  role    = "roles/compute.osAdminLogin"
  member  = "serviceAccount:service-${data.google_project.project.number}@compute-system.iam.gserviceaccount.com"
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.