此 Powershell 的 AZURE terraform 等价物是什么

What is the AZURE terraform equivalent of this Powershell

我正在尝试将 azure 应用分配给 Azure AD 角色。

在 PowerShell 中我可以做到这一点

## Import-Module AzureAD

## The role to assign to your app
$directoryRole = '[Role Name]' # i.e. 'Administrator'
$AppId = "[Guid]"
    
## Find the ObjectID of Role Name
$RoleId = (Get-AzureADDirectoryRole | Where-Object { $_.displayname -eq $directoryRole }).ObjectId
    
## Add the service principal to the directory role
Add-AzureADDirectoryRoleMember -ObjectId $RoleId -RefObjectId $AppId -Verbose

我如何使用 terraform 来实现?

Terraform 中没有可将 AD 角色分配给服务主体的资源。您可以获得有关 AD here. But if you don't mind, you can use the local-exec 到 运行 Terraform 中的 PowerShell 命令的所有资源。这将是一个解决方法。