drunk-pulumi-azure

VaultBuilder Class Overview

The 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 Overview

The VaultBuilderResults class encapsulates the results of building a Key Vault, providing methods to access the vault’s information and perform additional configurations.

VaultBuilderResults Class

Constructor

Purpose:

Initializes the VaultBuilderResults with the provided Key Vault information.

Sample Usage:

This constructor is private and is called internally by the from method.

from

Purpose:

Creates an instance of VaultBuilderResults from the provided Key Vault information.

Sample Usage:

const vaultInfo: KeyVaultInfo = {
  name: 'myKeyVault',
  id: 'vault-id',
  group: { resourceGroupName: 'myResourceGroup' },
};

const vaultResults = VaultBuilderResults.from(vaultInfo);

name

Purpose:

Gets the name of the Key Vault.

Sample Usage:

const vaultName = vaultResults.name;

group

Purpose:

Gets the resource group information of the Key Vault.

Sample Usage:

const resourceGroup = vaultResults.group;

id

Purpose:

Gets the ID of the Key Vault.

Sample Usage:

const vaultId = vaultResults.id;

info

Purpose:

Gets the Key Vault information.

Sample Usage:

const vaultInfo = vaultResults.info();

linkTo

Purpose:

Links the Key Vault to specified subnets and IP addresses.

Sample Usage:

vaultResults.linkTo({
  subnetIds: ['subnet-id-1', 'subnet-id-2'],
  ipAddresses: ['192.168.1.1', '192.168.1.2'],
});

privateLinkTo

Purpose:

Creates a private link to the Key Vault for specified subnets.

Sample Usage:

vaultResults.privateLinkTo(['subnet-id-1', 'subnet-id-2']);

addSecrets

Purpose:

Adds secrets to the Key Vault.

Sample Usage:

vaultResults.addSecrets({
  secretName: pulumi.secret('secretValue'),
});

addCerts

Purpose:

Adds certificates to the Key Vault.

Sample Usage:

vaultResults.addCerts({
  certName: {
    name: 'certName',
    // other CertBuilderType properties
  },
});

VaultBuilder Class

Constructor

Purpose:

Initializes the VaultBuilder with the provided arguments.

Sample Usage:

const vaultBuilder = new VaultBuilder({
  name: 'myKeyVault',
  group: { resourceGroupName: 'myResourceGroup' },
  // other necessary arguments
});

build

Purpose:

Builds the Key Vault and returns the results.

Sample Usage:

const vaultResults = vaultBuilder.build();
console.log(vaultResults);

Full Example

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);

Summary

This guideline should help developers understand and reuse the methods in the VaultBuilder class effectively.