英文:
Terraform issue with Keyvault access
问题
resource "azurerm_role_assignment" "vault_access" {
scope = azurerm_key_vault.vault.id
role_definition_id = "Contributor"
principal_id = data.azuread_group.access_audit_members.object_id
}
英文:
So I defined the kayvault definition in terraofrm and now looking to provide access to an AD group by the below definition, but I get error as
> Error: authorization.RoleAssignmentsClient#Create: Failure responding
> to request: StatusCode=400 -- Original Error: autorest/azure: Service
> returned an error. Status=400 Code="BadRequestFormat" Message="The
> request was incorrectly formatted."
here is the definition :
resource "azurerm_role_assignment" "vault_access" {
scope = azurerm_key_vault.vault.id
role_definition_id = "Contributor"
principal_id = data.azuread_group.access_audit_members.object_id
}
答案1
得分: 2
> Terraform问题与Keyvault访问
```haskell
role_definition_id = "Contributor"
由于您在代码中使用了role_definition_id
而不是role_definition_name
,请确保提供正确的Role Definition ID
,而不是角色名称。
以下是将角色分配给Azure AD组
范围内的Key Vault
的更新代码
provider "azurerm" {
features {}
}
data "azurerm_key_vault" "keyvault" {
name = "srikv12"
resource_group_name = "Sri"
}
data "azuread_group" "Adgroup" {
display_name = "keyvaultgroup"
security_enabled = true
}
resource "azurerm_role_assignment" "example" {
scope = data.azurerm_key_vault.keyvault.id
role_definition_name = "Contributor"
principal_id = data.azuread_group.Adgroup.object_id
}
Terraform应用:
执行以上代码后,将在Azure AD
范围内将Contributor
角色分配给Key Vault
有关更多关于resource "azurerm_role_assignment"
块的详细信息,请参阅registry.terraform
。
<details>
<summary>英文:</summary>
> Terraform issue with Keyvault access
```haskell
role_definition_id = "Contributor"
As you have used role_definition_id
instead of role_definition_name
in your code, please make sure to provide the correct Role Definition ID
instead of the role name.
Here is the updated code to assign the role to the Key Vault
at the Azure AD Group
scope
provider "azurerm" {
features {}
}
data "azurerm_key_vault" "keyvault" {
name = "srikv12"
resource_group_name = "Sri"
}
data "azuread_group" "Adgroup" {
display_name = "keyvaultgroup"
security_enabled = true
}
resource "azurerm_role_assignment" "example" {
scope = data.azurerm_key_vault.keyvault.id
role_definition_name = "Contributor"
principal_id = data.azuread_group.Adgroup.object_id
}
Terraform Apply:
Once the above code is executed, the Contributor
role will be assigned to the Key Vault
at the Azure AD
scope
Refer the registry.terraform
for more details about resource "azurerm_role_assignment
block.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论