We recommend using Azure Native.
azure.network.SubnetRouteTableAssociation
Explore with Pulumi AI
Associates a Route Table 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-resources",
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: "frontend",
resourceGroupName: example.name,
virtualNetworkName: exampleVirtualNetwork.name,
addressPrefixes: ["10.0.2.0/24"],
});
const exampleRouteTable = new azure.network.RouteTable("example", {
name: "example-routetable",
location: example.location,
resourceGroupName: example.name,
routes: [{
name: "example",
addressPrefix: "10.100.0.0/14",
nextHopType: "VirtualAppliance",
nextHopInIpAddress: "10.10.1.1",
}],
});
const exampleSubnetRouteTableAssociation = new azure.network.SubnetRouteTableAssociation("example", {
subnetId: exampleSubnet.id,
routeTableId: exampleRouteTable.id,
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
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="frontend",
resource_group_name=example.name,
virtual_network_name=example_virtual_network.name,
address_prefixes=["10.0.2.0/24"])
example_route_table = azure.network.RouteTable("example",
name="example-routetable",
location=example.location,
resource_group_name=example.name,
routes=[azure.network.RouteTableRouteArgs(
name="example",
address_prefix="10.100.0.0/14",
next_hop_type="VirtualAppliance",
next_hop_in_ip_address="10.10.1.1",
)])
example_subnet_route_table_association = azure.network.SubnetRouteTableAssociation("example",
subnet_id=example_subnet.id,
route_table_id=example_route_table.id)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v5/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-resources"),
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("frontend"),
ResourceGroupName: example.Name,
VirtualNetworkName: exampleVirtualNetwork.Name,
AddressPrefixes: pulumi.StringArray{
pulumi.String("10.0.2.0/24"),
},
})
if err != nil {
return err
}
exampleRouteTable, err := network.NewRouteTable(ctx, "example", &network.RouteTableArgs{
Name: pulumi.String("example-routetable"),
Location: example.Location,
ResourceGroupName: example.Name,
Routes: network.RouteTableRouteArray{
&network.RouteTableRouteArgs{
Name: pulumi.String("example"),
AddressPrefix: pulumi.String("10.100.0.0/14"),
NextHopType: pulumi.String("VirtualAppliance"),
NextHopInIpAddress: pulumi.String("10.10.1.1"),
},
},
})
if err != nil {
return err
}
_, err = network.NewSubnetRouteTableAssociation(ctx, "example", &network.SubnetRouteTableAssociationArgs{
SubnetId: exampleSubnet.ID(),
RouteTableId: exampleRouteTable.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-resources",
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 = "frontend",
ResourceGroupName = example.Name,
VirtualNetworkName = exampleVirtualNetwork.Name,
AddressPrefixes = new[]
{
"10.0.2.0/24",
},
});
var exampleRouteTable = new Azure.Network.RouteTable("example", new()
{
Name = "example-routetable",
Location = example.Location,
ResourceGroupName = example.Name,
Routes = new[]
{
new Azure.Network.Inputs.RouteTableRouteArgs
{
Name = "example",
AddressPrefix = "10.100.0.0/14",
NextHopType = "VirtualAppliance",
NextHopInIpAddress = "10.10.1.1",
},
},
});
var exampleSubnetRouteTableAssociation = new Azure.Network.SubnetRouteTableAssociation("example", new()
{
SubnetId = exampleSubnet.Id,
RouteTableId = exampleRouteTable.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.RouteTable;
import com.pulumi.azure.network.RouteTableArgs;
import com.pulumi.azure.network.inputs.RouteTableRouteArgs;
import com.pulumi.azure.network.SubnetRouteTableAssociation;
import com.pulumi.azure.network.SubnetRouteTableAssociationArgs;
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-resources")
.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("frontend")
.resourceGroupName(example.name())
.virtualNetworkName(exampleVirtualNetwork.name())
.addressPrefixes("10.0.2.0/24")
.build());
var exampleRouteTable = new RouteTable("exampleRouteTable", RouteTableArgs.builder()
.name("example-routetable")
.location(example.location())
.resourceGroupName(example.name())
.routes(RouteTableRouteArgs.builder()
.name("example")
.addressPrefix("10.100.0.0/14")
.nextHopType("VirtualAppliance")
.nextHopInIpAddress("10.10.1.1")
.build())
.build());
var exampleSubnetRouteTableAssociation = new SubnetRouteTableAssociation("exampleSubnetRouteTableAssociation", SubnetRouteTableAssociationArgs.builder()
.subnetId(exampleSubnet.id())
.routeTableId(exampleRouteTable.id())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
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: frontend
resourceGroupName: ${example.name}
virtualNetworkName: ${exampleVirtualNetwork.name}
addressPrefixes:
- 10.0.2.0/24
exampleRouteTable:
type: azure:network:RouteTable
name: example
properties:
name: example-routetable
location: ${example.location}
resourceGroupName: ${example.name}
routes:
- name: example
addressPrefix: 10.100.0.0/14
nextHopType: VirtualAppliance
nextHopInIpAddress: 10.10.1.1
exampleSubnetRouteTableAssociation:
type: azure:network:SubnetRouteTableAssociation
name: example
properties:
subnetId: ${exampleSubnet.id}
routeTableId: ${exampleRouteTable.id}
Create SubnetRouteTableAssociation Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SubnetRouteTableAssociation(name: string, args: SubnetRouteTableAssociationArgs, opts?: CustomResourceOptions);
@overload
def SubnetRouteTableAssociation(resource_name: str,
args: SubnetRouteTableAssociationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SubnetRouteTableAssociation(resource_name: str,
opts: Optional[ResourceOptions] = None,
route_table_id: Optional[str] = None,
subnet_id: Optional[str] = None)
func NewSubnetRouteTableAssociation(ctx *Context, name string, args SubnetRouteTableAssociationArgs, opts ...ResourceOption) (*SubnetRouteTableAssociation, error)
public SubnetRouteTableAssociation(string name, SubnetRouteTableAssociationArgs args, CustomResourceOptions? opts = null)
public SubnetRouteTableAssociation(String name, SubnetRouteTableAssociationArgs args)
public SubnetRouteTableAssociation(String name, SubnetRouteTableAssociationArgs args, CustomResourceOptions options)
type: azure:network:SubnetRouteTableAssociation
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 SubnetRouteTableAssociationArgs
- 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 SubnetRouteTableAssociationArgs
- 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 SubnetRouteTableAssociationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SubnetRouteTableAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SubnetRouteTableAssociationArgs
- 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 subnetRouteTableAssociationResource = new Azure.Network.SubnetRouteTableAssociation("subnetRouteTableAssociationResource", new()
{
RouteTableId = "string",
SubnetId = "string",
});
example, err := network.NewSubnetRouteTableAssociation(ctx, "subnetRouteTableAssociationResource", &network.SubnetRouteTableAssociationArgs{
RouteTableId: pulumi.String("string"),
SubnetId: pulumi.String("string"),
})
var subnetRouteTableAssociationResource = new SubnetRouteTableAssociation("subnetRouteTableAssociationResource", SubnetRouteTableAssociationArgs.builder()
.routeTableId("string")
.subnetId("string")
.build());
subnet_route_table_association_resource = azure.network.SubnetRouteTableAssociation("subnetRouteTableAssociationResource",
route_table_id="string",
subnet_id="string")
const subnetRouteTableAssociationResource = new azure.network.SubnetRouteTableAssociation("subnetRouteTableAssociationResource", {
routeTableId: "string",
subnetId: "string",
});
type: azure:network:SubnetRouteTableAssociation
properties:
routeTableId: string
subnetId: string
SubnetRouteTableAssociation Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The SubnetRouteTableAssociation resource accepts the following input properties:
- Route
Table stringId - The ID of the Route Table 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.
- Route
Table stringId - The ID of the Route Table 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.
- route
Table StringId - The ID of the Route Table 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.
- route
Table stringId - The ID of the Route Table 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.
- route_
table_ strid - The ID of the Route Table 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.
- route
Table StringId - The ID of the Route Table 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 SubnetRouteTableAssociation 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 SubnetRouteTableAssociation Resource
Get an existing SubnetRouteTableAssociation 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?: SubnetRouteTableAssociationState, opts?: CustomResourceOptions): SubnetRouteTableAssociation
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
route_table_id: Optional[str] = None,
subnet_id: Optional[str] = None) -> SubnetRouteTableAssociation
func GetSubnetRouteTableAssociation(ctx *Context, name string, id IDInput, state *SubnetRouteTableAssociationState, opts ...ResourceOption) (*SubnetRouteTableAssociation, error)
public static SubnetRouteTableAssociation Get(string name, Input<string> id, SubnetRouteTableAssociationState? state, CustomResourceOptions? opts = null)
public static SubnetRouteTableAssociation get(String name, Output<String> id, SubnetRouteTableAssociationState 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.
- Route
Table stringId - The ID of the Route Table 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.
- Route
Table stringId - The ID of the Route Table 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.
- route
Table StringId - The ID of the Route Table 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.
- route
Table stringId - The ID of the Route Table 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.
- route_
table_ strid - The ID of the Route Table 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.
- route
Table StringId - The ID of the Route Table 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 Route Table Associations can be imported using the resource id
of the Subnet, e.g.
$ pulumi import azure:network/subnetRouteTableAssociation:SubnetRouteTableAssociation 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.