Cloud Run 服務中的自訂服務帳戶

將自訂服務帳戶對應至 Cloud Run 服務

程式碼範例

Terraform

如要瞭解如何套用或移除 Terraform 設定,請參閱「基本 Terraform 指令」。 詳情請參閱 Terraform供應商參考說明文件

resource "google_service_account" "cloudrun_service_identity" {
  account_id = "my-service-account"
}

resource "google_cloud_run_v2_service" "default" {
  name     = "id-service"
  location = "us-central1"

  deletion_protection = false # set to "true" in production

  template {
    containers {
      image = "us-docker.pkg.dev/cloudrun/container/hello"
    }
    service_account = google_service_account.cloudrun_service_identity.email
  }
}

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽器