【问题标题】:Sharing custom images within an organization in GCP在 GCP 中的组织内共享自定义图像
【发布时间】:2020-08-06 04:12:34
【问题描述】:

我正在尝试在组织中的项目之间共享 GCP 中的自定义图像。

1) 项目 A

2) 项目 B

我所有的自定义图像都在项目 A 中。

我想将项目 A 的图像分享给项目 B

根据文档,我运行以下命令将图像共享到项目 B

gcloud projects add-iam-policy-binding projecta --member serviceAccount:xxxxxx@cloudservices.gserviceaccount.com --role roles/compute.imageUser

我正在使用 Terraform 来配置实例。在 terraform 中,我指定从项目 A 中获取图像。

  boot_disk {
    initialize_params {
      image = "projects/project_A/global/images/custom_image"
    }
  }

我收到以下错误

Error: Error creating instance: googleapi: Error 403: Required 'compute.images.useReadOnly' permission for 'projects/project_A/global/images/custom_image', forbidden

谁能帮帮我....

【问题讨论】:

    标签: google-cloud-platform google-compute-engine terraform google-cloud-iam terraform-provider-gcp


    【解决方案1】:

    我猜文档是针对部署管理器的,而不是针对 Terraform,您运行的命令将角色授予服务帐户 xxxxxx@cloudservices.gserviceaccount.com,但 Terraform 默认不使用该帐户。

    您需要确保 Terraform 拥有足够的权限。 You may supply xxxxxx@cloudservices.gserviceaccount.com to Terraform 或为 Terraform 创建一个新的服务帐户并将 roles/compute.imageUser 授予它。

    【讨论】:

      【解决方案2】:

      您刚刚完成了granti an service account a proper permissions to share your images across your organisation 的第一步。需要roles/compute.imageUser 角色才能执行此操作。

      您的 Terraform 配置看起来也不错(您必须确保指向您的图像的 self_link 正确(请参阅 this documentation 以确保 Terraform 配置中的 image 值正确)。

      还要确保您是@Ken Hung 的回答中所述的providing proper service account credentials to Terraform

      【讨论】:

        猜你喜欢
        • 2013-08-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-15
        • 2014-10-20
        • 2017-07-03
        • 2022-01-09
        相关资源
        最近更新 更多