无法使用 Terraform 创建 Google 存储传输作业

Cannot crerate Google Storage Transfer Job with Terraform

我正在尝试通过 Terraform 创建一个存储传输作业​​:

resource "google_storage_transfer_job" "goout_storage_backup" {
  description = "my-transfer-job"
  project = "my-project"
  transfer_spec {
    object_conditions {
      max_time_elapsed_since_last_modification = "86400s"
    }
    transfer_options {
      delete_objects_from_source_after_transfer  = false
      delete_objects_unique_in_sink              = false
      overwrite_objects_already_existing_in_sink = true
    }
    gcs_data_source {
      bucket_name = "source"
    }
    gcs_data_sink {
      bucket_name = "target"
    }
  }
  schedule {
    schedule_start_date {
      year  = 1970
      month = 01
      day   = 1
    }
    start_time_of_day {
      hours   = 4
      minutes = 27
      seconds = 0
      nanos   = 42
    }
  }
}

使用此脚本可以轻松管理我现有的作业,但是 Terraform 拒绝创建任何新的传输作业:

Error: googleapi: Error 400: Failed to obtain the location of the Google Cloud Storage (GCS) bucket source due to insufficient permissions. Please verify that the necessary permissions have been granted., failedPrecondition

但是我的用户是 owner,我也尝试分配 Storage Transfer AdminStorage Admin 但没有成功。

通过 Terraform 创建传输作业时,目标存储桶必须之前已分配传输服务帐户。分配这些解决了问题。