首页 > 解决方案 > 如何在 terraform 上使用 azurerm 提供程序创建 appRoles

问题描述

我正在尝试使用迄今为止非常成功的 Terraform 设置我的天蓝色基础设施。我们的应用程序开发团队需要在 AzureAD 应用程序的清单中定义应用程序特定角色,我们目前通过 Azure 门户处理这些角色,只需修改清单即可:

"appRoles": [
    {
        "allowedMemberTypes": [
        "Application"
        ],
        "displayName": "SurveyCreator",
        "id": "1b4f816e-5eaf-48b9-8613-7923830595ad",
        "isEnabled": true,
        "description": "Creators can create Surveys",
        "value": "SurveyCreator"
    }
]

使用 Terraform 我创建了一个azurerm_azuread_application,现在想要相应地修改清单。

resource "azurerm_azuread_application" "test" {
  name                       = "APP"
  homepage                   = "http://APPHOMEPAGE"
  identifier_uris            = ["http://APPHOMEPAGE"]
  reply_urls                 = ["http://APPHOMEPAGE/REPLYURL"]
  available_to_other_tenants = false
  oauth2_allow_implicit_flow = false
}

有没有办法只使用 Terraform 来实现这一点?

标签: azureazure-active-directoryterraform

解决方案


要创建 App 角色,您可以参考azuread_application_app_role.

resource "azuread_application" "example" {
  name = "example"
}

resource "azuread_application_app_role" "example" {
  application_object_id = azuread_application.example.id
  allowed_member_types  = ["User"]
  description           = "Admins can manage roles and perform all task actions"
  display_name          = "Admin"
  is_enabled            = true
  value                 = "administer"
}

推荐阅读