SubnetNatGatewayAssociation
Associates a NAT Gateway with a Subnet within a Virtual Network.
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 = "East US 2",
});
var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new Azure.Network.VirtualNetworkArgs
{
AddressSpaces =
{
"10.0.0.0/16",
},
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
});
var exampleSubnet = new Azure.Network.Subnet("exampleSubnet", new Azure.Network.SubnetArgs
{
ResourceGroupName = exampleResourceGroup.Name,
VirtualNetworkName = exampleVirtualNetwork.Name,
AddressPrefixes =
{
"10.0.2.0/24",
},
});
var exampleNatGateway = new Azure.Network.NatGateway("exampleNatGateway", new Azure.Network.NatGatewayArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
});
var exampleSubnetNatGatewayAssociation = new Azure.Network.SubnetNatGatewayAssociation("exampleSubnetNatGatewayAssociation", new Azure.Network.SubnetNatGatewayAssociationArgs
{
SubnetId = exampleSubnet.Id,
NatGatewayId = exampleNatGateway.Id,
});
}
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v3/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v3/go/azure/network"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
Location: pulumi.String("East US 2"),
})
if err != nil {
return err
}
exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "exampleVirtualNetwork", &network.VirtualNetworkArgs{
AddressSpaces: pulumi.StringArray{
pulumi.String("10.0.0.0/16"),
},
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
})
if err != nil {
return err
}
exampleSubnet, err := network.NewSubnet(ctx, "exampleSubnet", &network.SubnetArgs{
ResourceGroupName: exampleResourceGroup.Name,
VirtualNetworkName: exampleVirtualNetwork.Name,
AddressPrefixes: pulumi.StringArray{
pulumi.String("10.0.2.0/24"),
},
})
if err != nil {
return err
}
exampleNatGateway, err := network.NewNatGateway(ctx, "exampleNatGateway", &network.NatGatewayArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
})
if err != nil {
return err
}
_, err = network.NewSubnetNatGatewayAssociation(ctx, "exampleSubnetNatGatewayAssociation", &network.SubnetNatGatewayAssociationArgs{
SubnetId: exampleSubnet.ID(),
NatGatewayId: exampleNatGateway.ID(),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="East US 2")
example_virtual_network = azure.network.VirtualNetwork("exampleVirtualNetwork",
address_spaces=["10.0.0.0/16"],
location=example_resource_group.location,
resource_group_name=example_resource_group.name)
example_subnet = azure.network.Subnet("exampleSubnet",
resource_group_name=example_resource_group.name,
virtual_network_name=example_virtual_network.name,
address_prefixes=["10.0.2.0/24"])
example_nat_gateway = azure.network.NatGateway("exampleNatGateway",
location=example_resource_group.location,
resource_group_name=example_resource_group.name)
example_subnet_nat_gateway_association = azure.network.SubnetNatGatewayAssociation("exampleSubnetNatGatewayAssociation",
subnet_id=example_subnet.id,
nat_gateway_id=example_nat_gateway.id)import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "East US 2"});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("exampleVirtualNetwork", {
addressSpaces: ["10.0.0.0/16"],
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
});
const exampleSubnet = new azure.network.Subnet("exampleSubnet", {
resourceGroupName: exampleResourceGroup.name,
virtualNetworkName: exampleVirtualNetwork.name,
addressPrefixes: ["10.0.2.0/24"],
});
const exampleNatGateway = new azure.network.NatGateway("exampleNatGateway", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
});
const exampleSubnetNatGatewayAssociation = new azure.network.SubnetNatGatewayAssociation("exampleSubnetNatGatewayAssociation", {
subnetId: exampleSubnet.id,
natGatewayId: exampleNatGateway.id,
});Create a SubnetNatGatewayAssociation Resource
new SubnetNatGatewayAssociation(name: string, args: SubnetNatGatewayAssociationArgs, opts?: CustomResourceOptions);def SubnetNatGatewayAssociation(resource_name, opts=None, nat_gateway_id=None, subnet_id=None, __props__=None);func NewSubnetNatGatewayAssociation(ctx *Context, name string, args SubnetNatGatewayAssociationArgs, opts ...ResourceOption) (*SubnetNatGatewayAssociation, error)public SubnetNatGatewayAssociation(string name, SubnetNatGatewayAssociationArgs args, CustomResourceOptions? opts = null)- 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.
- opts ResourceOptions
- A bag of options that control this 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.
SubnetNatGatewayAssociation Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
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_ 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the SubnetNatGatewayAssociation resource produces the following output properties:
Look up an 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): SubnetNatGatewayAssociationstatic get(resource_name, id, opts=None, nat_gateway_id=None, subnet_id=None, __props__=None);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)- 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.
The following state arguments are supported:
- 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.
Package Details
- Repository
- https://github.com/pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.