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

We recommend using Azure Native.

Azure Classic v5.58.0 published on Saturday, Dec 2, 2023 by Pulumi

azure.network.SubnetRouteTableAssociation

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.58.0 published on Saturday, Dec 2, 2023 by Pulumi

    Associates a Route Table with a Subnet within a Virtual Network.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
        {
            Location = "West Europe",
        });
    
        var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new()
        {
            AddressSpaces = new[]
            {
                "10.0.0.0/16",
            },
            Location = exampleResourceGroup.Location,
            ResourceGroupName = exampleResourceGroup.Name,
        });
    
        var exampleSubnet = new Azure.Network.Subnet("exampleSubnet", new()
        {
            ResourceGroupName = exampleResourceGroup.Name,
            VirtualNetworkName = exampleVirtualNetwork.Name,
            AddressPrefixes = new[]
            {
                "10.0.2.0/24",
            },
        });
    
        var exampleRouteTable = new Azure.Network.RouteTable("exampleRouteTable", new()
        {
            Location = exampleResourceGroup.Location,
            ResourceGroupName = exampleResourceGroup.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("exampleSubnetRouteTableAssociation", new()
        {
            SubnetId = exampleSubnet.Id,
            RouteTableId = exampleRouteTable.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 {
    		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
    			Location: pulumi.String("West Europe"),
    		})
    		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
    		}
    		exampleRouteTable, err := network.NewRouteTable(ctx, "exampleRouteTable", &network.RouteTableArgs{
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.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, "exampleSubnetRouteTableAssociation", &network.SubnetRouteTableAssociationArgs{
    			SubnetId:     exampleSubnet.ID(),
    			RouteTableId: exampleRouteTable.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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 exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
                .location("West Europe")
                .build());
    
            var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()        
                .addressSpaces("10.0.0.0/16")
                .location(exampleResourceGroup.location())
                .resourceGroupName(exampleResourceGroup.name())
                .build());
    
            var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()        
                .resourceGroupName(exampleResourceGroup.name())
                .virtualNetworkName(exampleVirtualNetwork.name())
                .addressPrefixes("10.0.2.0/24")
                .build());
    
            var exampleRouteTable = new RouteTable("exampleRouteTable", RouteTableArgs.builder()        
                .location(exampleResourceGroup.location())
                .resourceGroupName(exampleResourceGroup.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());
    
        }
    }
    
    import pulumi
    import pulumi_azure as azure
    
    example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
    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_route_table = azure.network.RouteTable("exampleRouteTable",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.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("exampleSubnetRouteTableAssociation",
        subnet_id=example_subnet.id,
        route_table_id=example_route_table.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
    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 exampleRouteTable = new azure.network.RouteTable("exampleRouteTable", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
        routes: [{
            name: "example",
            addressPrefix: "10.100.0.0/14",
            nextHopType: "VirtualAppliance",
            nextHopInIpAddress: "10.10.1.1",
        }],
    });
    const exampleSubnetRouteTableAssociation = new azure.network.SubnetRouteTableAssociation("exampleSubnetRouteTableAssociation", {
        subnetId: exampleSubnet.id,
        routeTableId: exampleRouteTable.id,
    });
    
    resources:
      exampleResourceGroup:
        type: azure:core:ResourceGroup
        properties:
          location: West Europe
      exampleVirtualNetwork:
        type: azure:network:VirtualNetwork
        properties:
          addressSpaces:
            - 10.0.0.0/16
          location: ${exampleResourceGroup.location}
          resourceGroupName: ${exampleResourceGroup.name}
      exampleSubnet:
        type: azure:network:Subnet
        properties:
          resourceGroupName: ${exampleResourceGroup.name}
          virtualNetworkName: ${exampleVirtualNetwork.name}
          addressPrefixes:
            - 10.0.2.0/24
      exampleRouteTable:
        type: azure:network:RouteTable
        properties:
          location: ${exampleResourceGroup.location}
          resourceGroupName: ${exampleResourceGroup.name}
          routes:
            - name: example
              addressPrefix: 10.100.0.0/14
              nextHopType: VirtualAppliance
              nextHopInIpAddress: 10.10.1.1
      exampleSubnetRouteTableAssociation:
        type: azure:network:SubnetRouteTableAssociation
        properties:
          subnetId: ${exampleSubnet.id}
          routeTableId: ${exampleRouteTable.id}
    

    Create SubnetRouteTableAssociation Resource

    new SubnetRouteTableAssociation(name: string, args: SubnetRouteTableAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def SubnetRouteTableAssociation(resource_name: str,
                                    opts: Optional[ResourceOptions] = None,
                                    route_table_id: Optional[str] = None,
                                    subnet_id: Optional[str] = None)
    @overload
    def SubnetRouteTableAssociation(resource_name: str,
                                    args: SubnetRouteTableAssociationArgs,
                                    opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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:

    RouteTableId string

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    SubnetId string

    The ID of the Subnet. Changing this forces a new resource to be created.

    RouteTableId string

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    SubnetId string

    The ID of the Subnet. Changing this forces a new resource to be created.

    routeTableId String

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    subnetId String

    The ID of the Subnet. Changing this forces a new resource to be created.

    routeTableId string

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    subnetId string

    The ID of the Subnet. Changing this forces a new resource to be created.

    route_table_id str

    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.

    routeTableId String

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    subnetId 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.
    The following state arguments are supported:
    RouteTableId string

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    SubnetId string

    The ID of the Subnet. Changing this forces a new resource to be created.

    RouteTableId string

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    SubnetId string

    The ID of the Subnet. Changing this forces a new resource to be created.

    routeTableId String

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    subnetId String

    The ID of the Subnet. Changing this forces a new resource to be created.

    routeTableId string

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    subnetId string

    The ID of the Subnet. Changing this forces a new resource to be created.

    route_table_id str

    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.

    routeTableId String

    The ID of the Route Table which should be associated with the Subnet. Changing this forces a new resource to be created.

    subnetId 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
    

    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.

    Azure Classic v5.58.0 published on Saturday, Dec 2, 2023 by Pulumi