如何使用Terraform将现有的rbac角色附加到Azure VM?

问题描述 投票:0回答:1

我正在使用Terraform创建Azure虚拟机。但我不知道该如何附加现有的rbac角色。有没有一种方法,而无需为角色定义/附加创建单独的资源?如果需要单独的资源怎么办,仅知道rbac角色名称?

azure virtual-machine terraform rbac
1个回答
0
投票

我相信您正在寻找的是azurerm_role_definition数据源,它使您可以将已经存在的角色定义导入terraform。

请参见文档here

示例:

data "azurerm_subscription" "primary" {}

data "azurerm_role_definition" "my_role" {
  ### Specify either role_definition_id or name of the existing role
  # role_definition_id = "00000000-0000-0000-0000-000000000000"
  # name               = "MyRoleDefinition"

  scope = data.azurerm_subscription.primary.id
}
© www.soinside.com 2019 - 2024. All rights reserved.