【问题标题】:Terraform: "Wrong number of parts to Binding id" error message when attempting to import user-role bindTerraform:尝试导入用户角色绑定时出现“绑定 id 的零件数量错误”错误消息
【发布时间】:2021-09-20 04:12:17
【问题描述】:

我正在使用带有模块 google_project_iam_binding 的 Terraform 在 Terraform 文件中声明一个已经存在的资源,该文件具有之前已声明和导入的资源(但不是使用该模块)。

被声明后,terraform plan -out my-terraform-project.plan被执行,没有发现任何问题(说明会创建资源)。但是,如果我尝试使用 terraform import google_project_iam_binding.log-writer my-terraform-project 导入资源,我会得到:Error: Wrong number of parts to Binding id [feltboard-dev-devops]; expected 'resource_name role [condition_title]'.

这是我在 terraform 文件中的内容:

resource "google_project_iam_binding" "log-writer" {
  project             = "my-terraform-project"
  role                = "roles/logging.logWriter"
  members             = [
    "serviceAccount:log-writer-account@my-terraform-project.iam.gserviceaccount.com",
  ]
}

日志文件显示:

2021/07/09 14:32:33 [ERROR] <root>: eval: *terraform.EvalImportState, err: Wrong number of parts to Binding id [my-terraform-project]; expected 'resource_name role [condition_title]'.

2021/07/09 14:32:33 [ERROR] <root>: eval: *terraform.EvalSequence, err: Wrong number of parts to Binding id [my-terraform-project]; expected 'resource_name role [condition_title]'.

服务帐户存在,已在 terraform 文件中声明并导入。我尝试使用模块google_project_iam_binding,但得到了相同的结果。我没有注意到与related terraform doc page 中的示例有任何显着不同。我还尝试在示例中包含condition {... 部分,但仍然无法导入资源。任何建议表示赞赏。

【问题讨论】:

标签: google-cloud-platform binding terraform roles


【解决方案1】:

导入命令不完整。应该是的

terraform import google_project_iam_binding.log-writer "my-terraform-project roles/logging.logWriter"

【讨论】:

    猜你喜欢
    • 2019-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-25
    • 2021-02-20
    • 2021-09-13
    相关资源
    最近更新 更多