gpt4 book ai didi

azure - 如何使用 Terraform 在数据工厂的服务总线中添加角色分配?

转载 作者:行者123 更新时间:2023-12-03 07:01:19 25 4
gpt4 key购买 nike

在服务总线中,我尝试添加数据工厂的权限。所以最后它应该看起来像这样:

Expected result

我已经使用 terraform 创建了资源,但角色分配由于某种原因不起作用。

# Create Data Factory
resource "azurerm_data_factory" "adf" {
name = var.adf_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
identity {
type = "SystemAssigned"
}
}

# Create Service Bus
resource "azurerm_servicebus_namespace" "sb_namespace" {
name = var.sb_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
sku = "Standard"
identity {
type = "SystemAssigned"
}
}

# Create queue
resource "azurerm_servicebus_queue" "sb_queue" {
name = var.sb_message_queue_name
namespace_id = azurerm_servicebus_namespace.sb_namespace.id
max_size_in_megabytes = 1024
}

# Assign Data Factory to the Service Bus
resource "azurerm_role_assignment" "roleassignment_sb" {
scope = azurerm_data_factory.adf.id
role_definition_name = "Azure Service Bus Data Sender"
principal_id = azurerm_servicebus_namespace.sb_namespace.identity[0].principal_id
depends_on = [
azurerm_data_factory.adf
]
}

最佳答案

发现问题了。我必须与主要来源交换范围...所以正确的代码是:

# Assign Data Factory to the Service Bus
resource "azurerm_role_assignment" "roleassignment_sb" {
scope = azurerm_servicebus_namespace.sb_namespace.id
role_definition_name = "Azure Service Bus Data Sender"
principal_id = azurerm_data_factory.adf.identity[0].principal_id
}

关于azure - 如何使用 Terraform 在数据工厂的服务总线中添加角色分配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72316456/

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