Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use Azure Key Vault Python SDK to add access policy?

I’m trying to find a way to dynamically add new access policies to an Azure Key Vault resource.

My base stack is Pulumi (azure-native) which doesn’t provide the functionality to do that; it only allows to add access policies when creating the Key Vault resource.

Apparently, there are some Python SDKs for working with Azure Key Vault, but I couldn’t find a way to use them for managing access policies.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Does any of the Azure Key Vault Python SDKs provide a way to add access policies to Key Vault? If not, what are my choices (alternative solutions) here?

>Solution :

Manages a Key Vault Access Policy.

import pulumi
import pulumi_azure as azure

current = azure.core.get_client_config()
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_key_vault = azure.keyvault.KeyVault("exampleKeyVault",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    tenant_id=current.tenant_id,
    sku_name="premium")
example_access_policy = azure.keyvault.AccessPolicy("exampleAccessPolicy",
    key_vault_id=example_key_vault.id,
    tenant_id=current.tenant_id,
    object_id=current.object_id,
    key_permissions=["Get"],
    secret_permissions=["Get"])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading