1. Packages
  2. Azure Classic
  3. API Docs
  4. network
  5. NatGatewayPublicIpPrefixAssociation

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Manages the association between a Nat Gateway and a Public IP Prefix.

    Example Usage

    using Pulumi;
    using Azure = Pulumi.Azure;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
            {
                Location = "West Europe",
            });
            var examplePublicIpPrefix = new Azure.Network.PublicIpPrefix("examplePublicIpPrefix", new Azure.Network.PublicIpPrefixArgs
            {
                Location = exampleResourceGroup.Location,
                ResourceGroupName = exampleResourceGroup.Name,
                PrefixLength = 30,
                Zones = 
                {
                    "1",
                },
            });
            var exampleNatGateway = new Azure.Network.NatGateway("exampleNatGateway", new Azure.Network.NatGatewayArgs
            {
                Location = exampleResourceGroup.Location,
                ResourceGroupName = exampleResourceGroup.Name,
                SkuName = "Standard",
            });
            var exampleNatGatewayPublicIpPrefixAssociation = new Azure.Network.NatGatewayPublicIpPrefixAssociation("exampleNatGatewayPublicIpPrefixAssociation", new Azure.Network.NatGatewayPublicIpPrefixAssociationArgs
            {
                NatGatewayId = exampleNatGateway.Id,
                PublicIpPrefixId = examplePublicIpPrefix.Id,
            });
        }
    
    }
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/network"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
    			Location: pulumi.String("West Europe"),
    		})
    		if err != nil {
    			return err
    		}
    		examplePublicIpPrefix, err := network.NewPublicIpPrefix(ctx, "examplePublicIpPrefix", &network.PublicIpPrefixArgs{
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.Name,
    			PrefixLength:      pulumi.Int(30),
    			Zones: pulumi.String{
    				"1",
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleNatGateway, err := network.NewNatGateway(ctx, "exampleNatGateway", &network.NatGatewayArgs{
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.Name,
    			SkuName:           pulumi.String("Standard"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = network.NewNatGatewayPublicIpPrefixAssociation(ctx, "exampleNatGatewayPublicIpPrefixAssociation", &network.NatGatewayPublicIpPrefixAssociationArgs{
    			NatGatewayId:     exampleNatGateway.ID(),
    			PublicIpPrefixId: examplePublicIpPrefix.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    

    Example coming soon!

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
    const examplePublicIpPrefix = new azure.network.PublicIpPrefix("examplePublicIpPrefix", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
        prefixLength: 30,
        zones: ["1"],
    });
    const exampleNatGateway = new azure.network.NatGateway("exampleNatGateway", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
        skuName: "Standard",
    });
    const exampleNatGatewayPublicIpPrefixAssociation = new azure.network.NatGatewayPublicIpPrefixAssociation("exampleNatGatewayPublicIpPrefixAssociation", {
        natGatewayId: exampleNatGateway.id,
        publicIpPrefixId: examplePublicIpPrefix.id,
    });
    
    import pulumi
    import pulumi_azure as azure
    
    example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
    example_public_ip_prefix = azure.network.PublicIpPrefix("examplePublicIpPrefix",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name,
        prefix_length=30,
        zones=["1"])
    example_nat_gateway = azure.network.NatGateway("exampleNatGateway",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name,
        sku_name="Standard")
    example_nat_gateway_public_ip_prefix_association = azure.network.NatGatewayPublicIpPrefixAssociation("exampleNatGatewayPublicIpPrefixAssociation",
        nat_gateway_id=example_nat_gateway.id,
        public_ip_prefix_id=example_public_ip_prefix.id)
    

    Example coming soon!

    Create NatGatewayPublicIpPrefixAssociation Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new NatGatewayPublicIpPrefixAssociation(name: string, args: NatGatewayPublicIpPrefixAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def NatGatewayPublicIpPrefixAssociation(resource_name: str,
                                            args: NatGatewayPublicIpPrefixAssociationArgs,
                                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def NatGatewayPublicIpPrefixAssociation(resource_name: str,
                                            opts: Optional[ResourceOptions] = None,
                                            nat_gateway_id: Optional[str] = None,
                                            public_ip_prefix_id: Optional[str] = None)
    func NewNatGatewayPublicIpPrefixAssociation(ctx *Context, name string, args NatGatewayPublicIpPrefixAssociationArgs, opts ...ResourceOption) (*NatGatewayPublicIpPrefixAssociation, error)
    public NatGatewayPublicIpPrefixAssociation(string name, NatGatewayPublicIpPrefixAssociationArgs args, CustomResourceOptions? opts = null)
    public NatGatewayPublicIpPrefixAssociation(String name, NatGatewayPublicIpPrefixAssociationArgs args)
    public NatGatewayPublicIpPrefixAssociation(String name, NatGatewayPublicIpPrefixAssociationArgs args, CustomResourceOptions options)
    
    type: azure:network:NatGatewayPublicIpPrefixAssociation
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args NatGatewayPublicIpPrefixAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args NatGatewayPublicIpPrefixAssociationArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args NatGatewayPublicIpPrefixAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args NatGatewayPublicIpPrefixAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args NatGatewayPublicIpPrefixAssociationArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var natGatewayPublicIpPrefixAssociationResource = new Azure.Network.NatGatewayPublicIpPrefixAssociation("natGatewayPublicIpPrefixAssociationResource", new()
    {
        NatGatewayId = "string",
        PublicIpPrefixId = "string",
    });
    
    example, err := network.NewNatGatewayPublicIpPrefixAssociation(ctx, "natGatewayPublicIpPrefixAssociationResource", &network.NatGatewayPublicIpPrefixAssociationArgs{
    	NatGatewayId:     pulumi.String("string"),
    	PublicIpPrefixId: pulumi.String("string"),
    })
    
    var natGatewayPublicIpPrefixAssociationResource = new NatGatewayPublicIpPrefixAssociation("natGatewayPublicIpPrefixAssociationResource", NatGatewayPublicIpPrefixAssociationArgs.builder()
        .natGatewayId("string")
        .publicIpPrefixId("string")
        .build());
    
    nat_gateway_public_ip_prefix_association_resource = azure.network.NatGatewayPublicIpPrefixAssociation("natGatewayPublicIpPrefixAssociationResource",
        nat_gateway_id="string",
        public_ip_prefix_id="string")
    
    const natGatewayPublicIpPrefixAssociationResource = new azure.network.NatGatewayPublicIpPrefixAssociation("natGatewayPublicIpPrefixAssociationResource", {
        natGatewayId: "string",
        publicIpPrefixId: "string",
    });
    
    type: azure:network:NatGatewayPublicIpPrefixAssociation
    properties:
        natGatewayId: string
        publicIpPrefixId: string
    

    NatGatewayPublicIpPrefixAssociation Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The NatGatewayPublicIpPrefixAssociation resource accepts the following input properties:

    NatGatewayId string
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    PublicIpPrefixId string
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    NatGatewayId string
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    PublicIpPrefixId string
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    natGatewayId String
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    publicIpPrefixId String
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    natGatewayId string
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    publicIpPrefixId string
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    nat_gateway_id str
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    public_ip_prefix_id str
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    natGatewayId String
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    publicIpPrefixId String
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the NatGatewayPublicIpPrefixAssociation resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing NatGatewayPublicIpPrefixAssociation Resource

    Get an existing NatGatewayPublicIpPrefixAssociation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: NatGatewayPublicIpPrefixAssociationState, opts?: CustomResourceOptions): NatGatewayPublicIpPrefixAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            nat_gateway_id: Optional[str] = None,
            public_ip_prefix_id: Optional[str] = None) -> NatGatewayPublicIpPrefixAssociation
    func GetNatGatewayPublicIpPrefixAssociation(ctx *Context, name string, id IDInput, state *NatGatewayPublicIpPrefixAssociationState, opts ...ResourceOption) (*NatGatewayPublicIpPrefixAssociation, error)
    public static NatGatewayPublicIpPrefixAssociation Get(string name, Input<string> id, NatGatewayPublicIpPrefixAssociationState? state, CustomResourceOptions? opts = null)
    public static NatGatewayPublicIpPrefixAssociation get(String name, Output<String> id, NatGatewayPublicIpPrefixAssociationState state, CustomResourceOptions options)
    resources:  _:    type: azure:network:NatGatewayPublicIpPrefixAssociation    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    NatGatewayId string
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    PublicIpPrefixId string
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    NatGatewayId string
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    PublicIpPrefixId string
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    natGatewayId String
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    publicIpPrefixId String
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    natGatewayId string
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    publicIpPrefixId string
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    nat_gateway_id str
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    public_ip_prefix_id str
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
    natGatewayId String
    The ID of the Nat Gateway. Changing this forces a new resource to be created.
    publicIpPrefixId String
    The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.

    Import

    Associations between Nat Gateway and Public IP Prefixes can be imported using the resource id, e.g.

     $ pulumi import azure:network/natGatewayPublicIpPrefixAssociation:NatGatewayPublicIpPrefixAssociation example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPPrefixes/myPublicIpPrefix1"
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Viewing docs for Azure v4.42.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.