gpt4 book ai didi

google-cloud-platform - 使用 Terraform 创建 GCP 自定义 IAM 角色

转载 作者:行者123 更新时间:2023-12-03 21:24:13 25 4
gpt4 key购买 nike

我正在尝试使用 Terraform 在 GCP 中为我的实例创建自定义 IAM 角色。 AFIACT,以下应该可以工作,但它在我身上出错,提示我想要包含的标准角色无效。

resource "google_project_iam_custom_role" "my-instance-role" {
role_id = "myInstanceRole"
title = "My Instance Role"
description = "my custom iam role"
permissions = [
"roles/storage.objectCreator",
"roles/cloudkms.cryptoKeyEncrypter"
]
}

这是错误消息:
* google_project_iam_custom_role.my-instance-role: Error creating 
the custom project role My Instance Role: googleapi: Error 400:
Permission roles/storage.objectCreator is not valid., badRequest

Terraform 文档不是很清楚,但从我读过的内容来看,这应该有效。知道我在这里做错了什么吗?

最佳答案

好的。我想到了。您不能在自定义角色中包含 predefined GCP role。您必须指定 specific service permissions 。我真正想做的是:

resource "google_project_iam_custom_role" "my-instance-role" {
role_id = "myInstanceRole"
title = "My Instance Role"
description = "my custom iam role"
permissions = [
"storage.objects.create",
"cloudkms.cryptoKeyVersions.useToEncrypt"
]
}

这里的关键是预定义 GCP 角色之间的区别,例如“roles/storage.objectCreator”,它是 GCP 权限的集合,并单独使用这些单独的权限。在 Terraform 中创建自定义 IAM 角色时,您必须指定要应用的各个服务级别权限,例如“storage.objects.create”。

关于google-cloud-platform - 使用 Terraform 创建 GCP 自定义 IAM 角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49582977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com