繁体   English   中英

使用 Terraform 将新用户作为成员添加到 GCP Cloud Identity Group

[英]Add new users as members to GCP Cloud Identity Group using Terraform

我有gcp-organization-admins Cloud Identity 用户组,我想使用 Terraform 添加一个新用户user-01@example.com作为成员。

出现错误 -创建 GroupMembership 时出错:googleapi: got HTTP 响应代码 404。在此服务器上找不到请求的 URL /v1beta1/gcp-organization-admins@example.com/memberships?alt=json 任何人都可以建议如何解决这个问题。

仅供参考...作为测试,我能够使用 Terraform 模块https://github.com/terraform-google-modules/terraform-google-创建新的 Cloud Identity 用户组并向其中添加一些测试用户而没有任何问题团体

#=====================
# terraform.tfvars
#=====================
org_admin_user = ["user-01@example.com"]
org_admin_group = "gcp-organization-admins@example.com"

#=========================================================
# add-member.tf (adds user to google group as a member)
#=========================================================
resource "google_cloud_identity_group_membership" "user-01" {
  for_each = toset(var.org_admin_user)
  provider = google-beta
  group = var.org_admin_group
  preferred_member_key {
    id = each.key
  }
  roles {
    name = "MEMBER"
  }
}

这可能与此处记录的问题相同: https://github.com/hashicorp/terraform-provider-google/issues/7616

该错误中的评论提到以下内容:

I can work around the above issue by switching the order of the two roles in the resource, i.e.

From

  roles { name = "MANAGER" }
  roles { name = "MEMBER" }
to

  roles { name = "MEMBER" }
  roles { name = "MANAGER" }

https://github.com/hashicorp/terraform-provider-google/issues/7616#issuecomment-742779169

我遇到了同样的问题。 原来 Terraform 想要 GCP 组“名称”而不是 email 地址。

因此google_cloud_identity_group_membership资源块的组属性应该类似于“ groups/23097432uwhwiyo ”而不是“gcp-organization-admins@example.com”

您可以使用以下 gcloud 命令查找组“名称”:

gcloud identity groups describe "gcp-organization-admins@example.com"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM