我目前正在建立一个数据湖(Gen2)在Azure。我用Terraform提供所有的资源。然而,我遇到了一些权限不一致的地方。根据文档,可以使用RBAC和ACL为数据池设置权限。
我的选择是使用ACL,因为它允许对数据湖中的目录进行细粒度的权限。在数据湖中,我在其他目录中创建了一个目录raw,对于这些目录,某个group具有r-- (只读)默认权限。default意味着该目录下的所有对象都被分配与目录上的权限相同的权限。当该组中的用户试图使用Storage访问数据湖时,他们看不到存储帐户,也看不到目录所在的实际文件系统/容器。因此,它们无法访问它们具有只读权限的目录。
因此,我正在考虑为至少列出存储帐户和文件系统(容器)分配所需的权限。在评估现有角色时,我获得了以下权限:
Microsoft.Storage/storageAccounts/listKeys/actionMicrosoft.Storage/storageAccounts/read在申请许可1之后,没有任何改变。在申请权限2之后,组中的用户可以突然在数据池中做任何事情,就好像没有指定的ACL一样。
我现在的问题是:如何使用ACL(和RBAC)为不同组创建具有不同权限的目录的数据池,以便组实际上只能读写ACL中的目录?此外,它们应该能够列出它们可以访问某些目录的存储帐户和文件系统(容器)。
发布于 2021-03-15 17:08:49
我相信您还需要在整个文件夹层次结构上创建访问ACL,直到您试图读取的文件或文件夹,包括根容器。
因此,如果您的文件夹"raw“是在顶层创建的,那么您需要为该组创建以下ACL.
"/" --x (access)
"/raw" r-x (access)
"/raw" r-x (default)..。然后,默认的ACL将在创建的所有子文件夹和文件上给该组读取和执行ACL。
您还需要至少授予这个组对资源的Reader权限--如果您想限制对其他容器的访问,这可以在存储帐户上,或者仅在容器上。
可以使用ace Terraform资源的文件系统属性在容器上设置ACL,然后使用路径 Terraform资源在文件夹上设置ACL。
下面是一个示例,其中我将Azure Active Directory的object_id存储在一个名为aad_group_object_id的变量中。
# create the data lake
resource "azurerm_storage_account" "data_lake" {
....
}
# create a container named "acltest" with execute ACL for the group
resource "azurerm_storage_data_lake_gen2_filesystem" "data_lake_acl_test" {
name = "acltest"
storage_account_id = azurerm_storage_account.data_lake.id
ace {
type = "group"
scope = "access"
id = var.aad_group_object_id
permissions = "--x"
}
}
# create the folder "raw" and give read and execute access and default permissions to group
resource "azurerm_storage_data_lake_gen2_path" "folder_raw" {
path = "raw"
filesystem_name = azurerm_storage_data_lake_gen2_filesystem.data_lake_acl_test.name
storage_account_id = azurerm_storage_account.data_lake.id
resource = "directory"
ace {
type = "group"
scope = "access"
id = var.aad_group_object_id
permissions = "r-x"
}
ace {
type = "group"
scope = "default"
id = var.aad_group_object_id
permissions = "r-x"
}
}我还没有将其包括在代码示例中,但您还必须为拥有的组、所有者、掩码和其他身份添加ACL,这些标识被添加到根容器和子文件夹中。否则,您将在您的Terraform计划中看到,它每次都会尝试删除并重新创建它们。
您可以添加这个-不幸的是,您需要将它添加到您创建的每个文件夹,除非有人知道如何绕过它。
ace {
permissions = "---"
scope = "access"
type = "other"
}
ace {
permissions = "r-x"
scope = "access"
type = "group"
}
ace {
permissions = "r-x"
scope = "access"
type = "mask"
}
ace {
permissions = "rwx"
scope = "access"
type = "user"
}https://stackoverflow.com/questions/65320656
复制相似问题