We recommend using Azure Native.
azure.network.SubnetNatGatewayAssociation
Explore with Pulumi AI
Associates a NAT Gateway with a Subnet within a Virtual Network.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-nat-gateway-rg",
location: "West Europe",
});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
name: "example-network",
addressSpaces: ["10.0.0.0/16"],
location: example.location,
resourceGroupName: example.name,
});
const exampleSubnet = new azure.network.Subnet("example", {
name: "example-subnet",
resourceGroupName: example.name,
virtualNetworkName: exampleVirtualNetwork.name,
addressPrefixes: ["10.0.2.0/24"],
});
const exampleNatGateway = new azure.network.NatGateway("example", {
name: "example-natgateway",
location: example.location,
resourceGroupName: example.name,
});
const exampleSubnetNatGatewayAssociation = new azure.network.SubnetNatGatewayAssociation("example", {
subnetId: exampleSubnet.id,
natGatewayId: exampleNatGateway.id,
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-nat-gateway-rg",
location="West Europe")
example_virtual_network = azure.network.VirtualNetwork("example",
name="example-network",
address_spaces=["10.0.0.0/16"],
location=example.location,
resource_group_name=example.name)
example_subnet = azure.network.Subnet("example",
name="example-subnet",
resource_group_name=example.name,
virtual_network_name=example_virtual_network.name,
address_prefixes=["10.0.2.0/24"])
example_nat_gateway = azure.network.NatGateway("example",
name="example-natgateway",
location=example.location,
resource_group_name=example.name)
example_subnet_nat_gateway_association = azure.network.SubnetNatGatewayAssociation("example",
subnet_id=example_subnet.id,
nat_gateway_id=example_nat_gateway.id)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-nat-gateway-rg"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "example", &network.VirtualNetworkArgs{
Name: pulumi.String("example-network"),
AddressSpaces: pulumi.StringArray{
pulumi.String("10.0.0.0/16"),
},
Location: example.Location,
ResourceGroupName: example.Name,
})
if err != nil {
return err
}
exampleSubnet, err := network.NewSubnet(ctx, "example", &network.SubnetArgs{
Name: pulumi.String("example-subnet"),
ResourceGroupName: example.Name,
VirtualNetworkName: exampleVirtualNetwork.Name,
AddressPrefixes: pulumi.StringArray{
pulumi.String("10.0.2.0/24"),
},
})
if err != nil {
return err
}
exampleNatGateway, err := network.NewNatGateway(ctx, "example", &network.NatGatewayArgs{
Name: pulumi.String("example-natgateway"),
Location: example.Location,
ResourceGroupName: example.Name,
})
if err != nil {
return err
}
_, err = network.NewSubnetNatGatewayAssociation(ctx, "example", &network.SubnetNatGatewayAssociationArgs{
SubnetId: exampleSubnet.ID(),
NatGatewayId: exampleNatGateway.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-nat-gateway-rg",
Location = "West Europe",
});
var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("example", new()
{
Name = "example-network",
AddressSpaces = new[]
{
"10.0.0.0/16",
},
Location = example.Location,
ResourceGroupName = example.Name,
});
var exampleSubnet = new Azure.Network.Subnet("example", new()
{
Name = "example-subnet",
ResourceGroupName = example.Name,
VirtualNetworkName = exampleVirtualNetwork.Name,
AddressPrefixes = new[]
{
"10.0.2.0/24",
},
});
var exampleNatGateway = new Azure.Network.NatGateway("example", new()
{
Name = "example-natgateway",
Location = example.Location,
ResourceGroupName = example.Name,
});
var exampleSubnetNatGatewayAssociation = new Azure.Network.SubnetNatGatewayAssociation("example", new()
{
SubnetId = exampleSubnet.Id,
NatGatewayId = exampleNatGateway.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.network.NatGateway;
import com.pulumi.azure.network.NatGatewayArgs;
import com.pulumi.azure.network.SubnetNatGatewayAssociation;
import com.pulumi.azure.network.SubnetNatGatewayAssociationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-nat-gateway-rg")
.location("West Europe")
.build());
var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
.name("example-network")
.addressSpaces("10.0.0.0/16")
.location(example.location())
.resourceGroupName(example.name())
.build());
var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
.name("example-subnet")
.resourceGroupName(example.name())
.virtualNetworkName(exampleVirtualNetwork.name())
.addressPrefixes("10.0.2.0/24")
.build());
var exampleNatGateway = new NatGateway("exampleNatGateway", NatGatewayArgs.builder()
.name("example-natgateway")
.location(example.location())
.resourceGroupName(example.name())
.build());
var exampleSubnetNatGatewayAssociation = new SubnetNatGatewayAssociation("exampleSubnetNatGatewayAssociation", SubnetNatGatewayAssociationArgs.builder()
.subnetId(exampleSubnet.id())
.natGatewayId(exampleNatGateway.id())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-nat-gateway-rg
location: West Europe
exampleVirtualNetwork:
type: azure:network:VirtualNetwork
name: example
properties:
name: example-network
addressSpaces:
- 10.0.0.0/16
location: ${example.location}
resourceGroupName: ${example.name}
exampleSubnet:
type: azure:network:Subnet
name: example
properties:
name: example-subnet
resourceGroupName: ${example.name}
virtualNetworkName: ${exampleVirtualNetwork.name}
addressPrefixes:
- 10.0.2.0/24
exampleNatGateway:
type: azure:network:NatGateway
name: example
properties:
name: example-natgateway
location: ${example.location}
resourceGroupName: ${example.name}
exampleSubnetNatGatewayAssociation:
type: azure:network:SubnetNatGatewayAssociation
name: example
properties:
subnetId: ${exampleSubnet.id}
natGatewayId: ${exampleNatGateway.id}
Create SubnetNatGatewayAssociation Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SubnetNatGatewayAssociation(name: string, args: SubnetNatGatewayAssociationArgs, opts?: CustomResourceOptions);
@overload
def SubnetNatGatewayAssociation(resource_name: str,
args: SubnetNatGatewayAssociationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SubnetNatGatewayAssociation(resource_name: str,
opts: Optional[ResourceOptions] = None,
nat_gateway_id: Optional[str] = None,
subnet_id: Optional[str] = None)
func NewSubnetNatGatewayAssociation(ctx *Context, name string, args SubnetNatGatewayAssociationArgs, opts ...ResourceOption) (*SubnetNatGatewayAssociation, error)
public SubnetNatGatewayAssociation(string name, SubnetNatGatewayAssociationArgs args, CustomResourceOptions? opts = null)
public SubnetNatGatewayAssociation(String name, SubnetNatGatewayAssociationArgs args)
public SubnetNatGatewayAssociation(String name, SubnetNatGatewayAssociationArgs args, CustomResourceOptions options)
type: azure:network:SubnetNatGatewayAssociation
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 SubnetNatGatewayAssociationArgs
- 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 SubnetNatGatewayAssociationArgs
- 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 SubnetNatGatewayAssociationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SubnetNatGatewayAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SubnetNatGatewayAssociationArgs
- 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 subnetNatGatewayAssociationResource = new Azure.Network.SubnetNatGatewayAssociation("subnetNatGatewayAssociationResource", new()
{
NatGatewayId = "string",
SubnetId = "string",
});
example, err := network.NewSubnetNatGatewayAssociation(ctx, "subnetNatGatewayAssociationResource", &network.SubnetNatGatewayAssociationArgs{
NatGatewayId: pulumi.String("string"),
SubnetId: pulumi.String("string"),
})
var subnetNatGatewayAssociationResource = new SubnetNatGatewayAssociation("subnetNatGatewayAssociationResource", SubnetNatGatewayAssociationArgs.builder()
.natGatewayId("string")
.subnetId("string")
.build());
subnet_nat_gateway_association_resource = azure.network.SubnetNatGatewayAssociation("subnetNatGatewayAssociationResource",
nat_gateway_id="string",
subnet_id="string")
const subnetNatGatewayAssociationResource = new azure.network.SubnetNatGatewayAssociation("subnetNatGatewayAssociationResource", {
natGatewayId: "string",
subnetId: "string",
});
type: azure:network:SubnetNatGatewayAssociation
properties:
natGatewayId: string
subnetId: string
SubnetNatGatewayAssociation 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 SubnetNatGatewayAssociation resource accepts the following input properties:
- Nat
Gateway stringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the Subnet. Changing this forces a new resource to be created.
- Nat
Gateway stringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the Subnet. Changing this forces a new resource to be created.
- nat
Gateway StringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the Subnet. Changing this forces a new resource to be created.
- nat
Gateway stringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet
Id string - The ID of the Subnet. Changing this forces a new resource to be created.
- nat_
gateway_ strid - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet_
id str - The ID of the Subnet. Changing this forces a new resource to be created.
- nat
Gateway StringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the Subnet. Changing this forces a new resource to be created.
Outputs
All input properties are implicitly available as output properties. Additionally, the SubnetNatGatewayAssociation 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 SubnetNatGatewayAssociation Resource
Get an existing SubnetNatGatewayAssociation 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?: SubnetNatGatewayAssociationState, opts?: CustomResourceOptions): SubnetNatGatewayAssociation
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
nat_gateway_id: Optional[str] = None,
subnet_id: Optional[str] = None) -> SubnetNatGatewayAssociation
func GetSubnetNatGatewayAssociation(ctx *Context, name string, id IDInput, state *SubnetNatGatewayAssociationState, opts ...ResourceOption) (*SubnetNatGatewayAssociation, error)
public static SubnetNatGatewayAssociation Get(string name, Input<string> id, SubnetNatGatewayAssociationState? state, CustomResourceOptions? opts = null)
public static SubnetNatGatewayAssociation get(String name, Output<String> id, SubnetNatGatewayAssociationState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- Nat
Gateway stringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the Subnet. Changing this forces a new resource to be created.
- Nat
Gateway stringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the Subnet. Changing this forces a new resource to be created.
- nat
Gateway StringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the Subnet. Changing this forces a new resource to be created.
- nat
Gateway stringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet
Id string - The ID of the Subnet. Changing this forces a new resource to be created.
- nat_
gateway_ strid - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet_
id str - The ID of the Subnet. Changing this forces a new resource to be created.
- nat
Gateway StringId - The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the Subnet. Changing this forces a new resource to be created.
Import
Subnet NAT Gateway Associations can be imported using the resource id
of the Subnet, e.g.
$ pulumi import azure:network/subnetNatGatewayAssociation:SubnetNatGatewayAssociation association1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/virtualNetworks/myvnet1/subnets/mysubnet1
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.