Open kalzun opened 2 years ago
@kalzun thanks for opening this issue. Could you add the create_before_destroy = true
in azurerm_key_vault_access_policy block like below to see if the error goes away?
resource "azurerm_key_vault_access_policy" "test" {
key_vault_id = azurerm_key_vault.test.id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = "different-uuid"
key_permissions = [
"Create",
"Get",
]
secret_permissions = [
"Set",
"Get",
"Delete",
"Purge",
"Recover"
]
lifecycle {
create_before_destroy = true
}
}
Thank you for the suggestion. I tried adding the block as mentioned -- it still fails, with same error message as before.
keyvault.BaseClient#GetSecret: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure:
Service returned an error. Status=403 Code="Forbidden" Message="The user, group or application 'appid=000;oid=000;
iss=https://sts.windows.net/000/' does not have secrets get permission on key vault 'acctestkv;location=eastus'.
For help resolving this ssue, please see https://go.microsoft.com/fwlink/?linkid=2125287"
InnerError={"code":"AccessDenied"}
Is there an existing issue for this?
Community Note
Terraform Version
1.2.4
AzureRM Provider Version
3.12.0
Affected Resource(s)/Data Source(s)
azurerm_key_vault, azurerm_key_vault_access_policy, azurerm_key_vault_secret
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
When updating azurerm_key_vault_access_policy (or access policy in azurerm_key_vault) for a new object_id, and using:
depends_on = [ azurerm_key_vault_access_policy ]
, it should set access policy for this object_id before checking whether it has permission to read existingazurerm_key_vault_secret
.Actual Behaviour
Failing due to not having read permissions on existing
azurerm_key_vault_secrets
.Steps to Reproduce
I have written this test to reproduce it. See new object_id in
azurerm_key_vault_access_policy
inwithExternalAccessPolicyUpdateDifferentObjectId
, which is the reason for failing.Add the following to
key_vault_secret_resource_test.go
.Important Factoids
I discovered this when sharing the project to another developer, who of course gets their object_id, and not the one I had set when creating the resource initially.
References
No response