0

如何在 terraform 0.12 中解析这种数据类型

 variable "groups" {
    type = list(object({
        group_id = string
        permissions = list(string)
    }))
}

例子:

 groups = [
    {
        group_id = "gcp-org-admin"
        permissions = [ "roles/resourcemanager.organizationAdmin",
                        "roles/resourcemanager.folderViewer",
                        "roles/viewer",
                        "roles/iam.organizationRoleViewer",
                        "roles/orgpolicy.policyViewer"
                      ]  
    },
    {
        group_id = "gcp-security-ops"
        permissions = [ "roles/resourcemanager.folderViewer",
                        "roles/logging.viewer",
                        "roles/monitoring.editor",
                        "roles/iam.securityReviewer"
                      ]
    }]

对于每个组,我想将 group_id 和每个权限配对

  {
    group_id = "gcp-org-admin"
    permissions = "roles/resourcemanager.organizationAdmin"
  },
  {
    group_id = "gcp-org-admin"
    permissions = "roles/resourcemanager.folderViewer"
  },
  {
    group_id = "gcp-org-admin"
    permissions = "roles/viewer"
  }

想创建 organization_iam_resource

对于每个 group_id 中的每个权限,我必须创建一个资源。

有什么办法可以做到这一点

4

1 回答 1

0

看看这个例子,因为它向您展示了一个可能的答案以及与嵌套列表相关的一些问题:https ://github.com/hashicorp/terraform/issues/11036

于 2019-04-03T15:17:45.803 回答