VaultBuilder Class OverviewThe VaultBuilder class is designed to build and configure an Azure Key Vault instance with specific configurations such as secrets, certificates, and network settings.
VaultBuilderResults Class OverviewThe VaultBuilderResults class encapsulates the results of building a Key Vault, providing methods to access the vault’s information and perform additional configurations.
VaultBuilderResults ClassInitializes the VaultBuilderResults with the provided Key Vault information.
This constructor is private and is called internally by the from method.
fromCreates an instance of VaultBuilderResults from the provided Key Vault information.
const vaultInfo: KeyVaultInfo = {
name: 'myKeyVault',
id: 'vault-id',
group: { resourceGroupName: 'myResourceGroup' },
};
const vaultResults = VaultBuilderResults.from(vaultInfo);
nameGets the name of the Key Vault.
const vaultName = vaultResults.name;
groupGets the resource group information of the Key Vault.
const resourceGroup = vaultResults.group;
idGets the ID of the Key Vault.
const vaultId = vaultResults.id;
infoGets the Key Vault information.
const vaultInfo = vaultResults.info();
linkToLinks the Key Vault to specified subnets and IP addresses.
vaultResults.linkTo({
subnetIds: ['subnet-id-1', 'subnet-id-2'],
ipAddresses: ['192.168.1.1', '192.168.1.2'],
});
privateLinkToCreates a private link to the Key Vault for specified subnets.
vaultResults.privateLinkTo(['subnet-id-1', 'subnet-id-2']);
addSecretsAdds secrets to the Key Vault.
vaultResults.addSecrets({
secretName: pulumi.secret('secretValue'),
});
addCertsAdds certificates to the Key Vault.
vaultResults.addCerts({
certName: {
name: 'certName',
// other CertBuilderType properties
},
});
VaultBuilder ClassInitializes the VaultBuilder with the provided arguments.
const vaultBuilder = new VaultBuilder({
name: 'myKeyVault',
group: { resourceGroupName: 'myResourceGroup' },
// other necessary arguments
});
buildBuilds the Key Vault and returns the results.
const vaultResults = vaultBuilder.build();
console.log(vaultResults);
Here is a full example demonstrating how to use the VaultBuilder class:
import VaultBuilder from './Builder/VaultBuilder';
import { VaultBuilderArgs } from './types/vaultBuilder';
const args: VaultBuilderArgs = {
name: 'myKeyVault',
group: { resourceGroupName: 'myResourceGroup' },
// other necessary arguments
};
const vaultBuilder = new VaultBuilder(args);
const vaultResults = vaultBuilder.build();
vaultResults
.addSecrets({
secretName: pulumi.secret('secretValue'),
})
.addCerts({
certName: {
name: 'certName',
// other CertBuilderType properties
},
})
.linkTo({
subnetIds: ['subnet-id-1', 'subnet-id-2'],
ipAddresses: ['192.168.1.1', '192.168.1.2'],
})
.privateLinkTo(['subnet-id-1', 'subnet-id-2']);
console.log(vaultResults);
This guideline should help developers understand and reuse the methods in the VaultBuilder class effectively.