我想使用我知道如何操作的 terraform 创建 ADF 和存储帐户。在此之后,我想授予 ADF 身份访问存储帐户的权限。我可以使用 powershell 做到这一点。但是当我使用 powershell 时,幂等性问题就会出现。是否可以在不使用 powershell 的情况下通过 terraform 本身实现访问?
答案 0 :(得分:3)
您应该创建一个 azurerm_role_assignment
以授予 ADF 访问 Azure 存储帐户的权限。
请检查下面的示例。此代码段将 Storage Blob Data Reader
角色分配给 ADF。
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_data_factory" "example" {
name = "example524657"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
identity {
type = "SystemAssigned"
}
}
resource "azurerm_storage_account" "example" {
name = "examplestr524657"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "RAGRS"
}
resource "azurerm_role_assignment" "example" {
scope = azurerm_storage_account.example.id
role_definition_name = "Storage Blob Data Reader"
principal_id = azurerm_data_factory.example.identity[0].principal_id
}