我想在存储桶 bucket_A 上设置服务帐户 sa-email.com 的权限。
如何使用 terraform 进行如下配置?
- sa-email.com 可以在 bucket_A 中创建文件
- sa-email.com 无法删除 bucket_A 中的文件
更新:
现在在我的项目中,sa-email 是存储对象管理员。
resource "google_project_iam_member" "aaaa" {
member = "sa-email.com"
project = "pid"
role = "roles/storage.objectAdmin"
}
我的项目中有大约 20 个桶。
我只想将权限更改为一个存储桶。
我是否必须使用 google_storage_bucket_iam_member 来设置 20 个存储桶?
有没有办法做一点更新?
Update2:
我的解决方案
google_project_iam_member 带有“条件”
resource "google_project_iam_member" "aaaa" {
member = "sa-email.com"
project = "pid"
role = "roles/storage.objectAdmin"
condition {
title = " bucket can delete "
expression = "!resource.name.startsWith(\"projects/_/buckets/bucket_can_not_delete\")"
}
}
resource "google_project_iam_member" "bbbb" {
member = "sa-email.com"
project = "pid"
role = "roles/storage.objectCreator"
condition {
title = " bucket can not delete "
expression = "resource.name.startsWith(\"projects/_/buckets/bucket_can_not_delete\")"
}
}