How do I retrieve the URL of a new Azure Key Vault?
Introduction
In this guide, we will create an Azure Key Vault and retrieve its URL. Azure Key Vault is a cloud service for securely storing and accessing secrets. We will define the Key Vault resource and then output its URL.
Steps to Achieve
- Create an Azure Resource Group: This will hold the Key Vault.
- Create an Azure Key Vault: Define the properties required for the Key Vault.
- Export the Key Vault URL: Retrieve and output the URL of the created Key Vault.
Below is the complete example that accomplishes this.
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
// Create a Resource Group
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West US",
});
// Create an Azure Key Vault
const exampleKeyVault = new azure.keyvault.KeyVault("example", {
name: "example-keyvault",
location: example.location,
resourceGroupName: example.name,
tenantId: "00000000-0000-0000-0000-000000000000",
skuName: "standard",
});
export const vaultUrl = exampleKeyVault.vaultUri;
Key Points
- We start by defining the Azure provider to use Azure services.
- A
azurerm_resource_group
is created to hold our Key Vault. - The
azurerm_key_vault
resource is defined with necessary properties like name, location, and resource group details. - Finally, we use an output block to retrieve and display the Key Vault’s URL.
Summary
In this example, we’ve set up an Azure Key Vault and then retrieved its URL. This URL can be used to interact with the Key Vault securely.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.