drunk-pulumi-azure

AcrBuilder Class Documentation

1. Overview

The AcrBuilder class is designed to simplify the creation and configuration of Azure Container Registry (ACR) resources using Pulumi. This class follows the Builder pattern, providing a fluent interface for defining various aspects of an ACR, including SKU selection, network configurations, policies, and more.

2. Key Methods and Their Attributes

2.1. withSku(sku: AcrSkuBuilderType)

Configures the SKU for the Azure Container Registry.

2.2. withNetwork(props: AcrBuilderNetworkType)

Defines the network settings for the ACR.

2.3. withPolicies(policies: AcrBuilderPolicies)

Configures retention policies for the ACR.

Configures a private link for the ACR.

2.5. build(): registry.Registry

Builds and deploys the ACR instance based on the current configuration.

3. Example of Full Usage

Here’s a complete example demonstrating how to use the AcrBuilder with all available properties:

const acrBuilder = new AcrBuilder({
  resourceName: 'my-acr',
  resourceGroupName: 'my-resource-group',
  location: 'East US',
} as AcrBuilderArgs);

acrBuilder
  .withSku('Premium' as AcrSkuBuilderType)
  .withNetwork({
    privateEndpoint: {
      subnetIds: ['subnet-id-1', 'subnet-id-2'],
      privateIpAddress: '10.0.0.5',
      extraVnetIds: ['vnet-id-1', 'vnet-id-2'],
    },
    disableLocalAuth: true,
  } as AcrBuilderNetworkType)
  .withPolicies({
    retentionDay: 30,
  } as AcrBuilderPolicies)
  .withPrivateLink({
    privateEndpointSubnetIds: ['subnet-id-1', 'subnet-id-2'],
    privateDnsZoneId: 'dns-zone-id',
  });

const acrInstance = acrBuilder.build();

4. Conclusion

The AcrBuilder class provides a robust and flexible way to configure and deploy Azure Container Registry instances. By offering detailed configuration options for SKU, network settings, and policies, it allows developers to customize ACR deployments to meet specific needs.