1. Packages
  2. AWS
  3. API Docs
  4. ec2
  5. LocalGatewayRoute
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.ec2.LocalGatewayRoute

Explore with Pulumi AI

Manages an EC2 Local Gateway Route. More information can be found in the Outposts User Guide.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.ec2.LocalGatewayRoute("example", {
    destinationCidrBlock: "172.16.0.0/16",
    localGatewayRouteTableId: exampleAwsEc2LocalGatewayRouteTable.id,
    localGatewayVirtualInterfaceGroupId: exampleAwsEc2LocalGatewayVirtualInterfaceGroup.id,
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.ec2.LocalGatewayRoute("example",
    destination_cidr_block="172.16.0.0/16",
    local_gateway_route_table_id=example_aws_ec2_local_gateway_route_table["id"],
    local_gateway_virtual_interface_group_id=example_aws_ec2_local_gateway_virtual_interface_group["id"])
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.NewLocalGatewayRoute(ctx, "example", &ec2.LocalGatewayRouteArgs{
			DestinationCidrBlock:                pulumi.String("172.16.0.0/16"),
			LocalGatewayRouteTableId:            pulumi.Any(exampleAwsEc2LocalGatewayRouteTable.Id),
			LocalGatewayVirtualInterfaceGroupId: pulumi.Any(exampleAwsEc2LocalGatewayVirtualInterfaceGroup.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.Ec2.LocalGatewayRoute("example", new()
    {
        DestinationCidrBlock = "172.16.0.0/16",
        LocalGatewayRouteTableId = exampleAwsEc2LocalGatewayRouteTable.Id,
        LocalGatewayVirtualInterfaceGroupId = exampleAwsEc2LocalGatewayVirtualInterfaceGroup.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.LocalGatewayRoute;
import com.pulumi.aws.ec2.LocalGatewayRouteArgs;
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 LocalGatewayRoute("example", LocalGatewayRouteArgs.builder()
            .destinationCidrBlock("172.16.0.0/16")
            .localGatewayRouteTableId(exampleAwsEc2LocalGatewayRouteTable.id())
            .localGatewayVirtualInterfaceGroupId(exampleAwsEc2LocalGatewayVirtualInterfaceGroup.id())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:ec2:LocalGatewayRoute
    properties:
      destinationCidrBlock: 172.16.0.0/16
      localGatewayRouteTableId: ${exampleAwsEc2LocalGatewayRouteTable.id}
      localGatewayVirtualInterfaceGroupId: ${exampleAwsEc2LocalGatewayVirtualInterfaceGroup.id}
Copy

Create LocalGatewayRoute Resource

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

Constructor syntax

new LocalGatewayRoute(name: string, args: LocalGatewayRouteArgs, opts?: CustomResourceOptions);
@overload
def LocalGatewayRoute(resource_name: str,
                      args: LocalGatewayRouteArgs,
                      opts: Optional[ResourceOptions] = None)

@overload
def LocalGatewayRoute(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      destination_cidr_block: Optional[str] = None,
                      local_gateway_route_table_id: Optional[str] = None,
                      local_gateway_virtual_interface_group_id: Optional[str] = None)
func NewLocalGatewayRoute(ctx *Context, name string, args LocalGatewayRouteArgs, opts ...ResourceOption) (*LocalGatewayRoute, error)
public LocalGatewayRoute(string name, LocalGatewayRouteArgs args, CustomResourceOptions? opts = null)
public LocalGatewayRoute(String name, LocalGatewayRouteArgs args)
public LocalGatewayRoute(String name, LocalGatewayRouteArgs args, CustomResourceOptions options)
type: aws:ec2:LocalGatewayRoute
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. LocalGatewayRouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. LocalGatewayRouteArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. LocalGatewayRouteArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. LocalGatewayRouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. LocalGatewayRouteArgs
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 localGatewayRouteResource = new Aws.Ec2.LocalGatewayRoute("localGatewayRouteResource", new()
{
    DestinationCidrBlock = "string",
    LocalGatewayRouteTableId = "string",
    LocalGatewayVirtualInterfaceGroupId = "string",
});
Copy
example, err := ec2.NewLocalGatewayRoute(ctx, "localGatewayRouteResource", &ec2.LocalGatewayRouteArgs{
	DestinationCidrBlock:                pulumi.String("string"),
	LocalGatewayRouteTableId:            pulumi.String("string"),
	LocalGatewayVirtualInterfaceGroupId: pulumi.String("string"),
})
Copy
var localGatewayRouteResource = new LocalGatewayRoute("localGatewayRouteResource", LocalGatewayRouteArgs.builder()
    .destinationCidrBlock("string")
    .localGatewayRouteTableId("string")
    .localGatewayVirtualInterfaceGroupId("string")
    .build());
Copy
local_gateway_route_resource = aws.ec2.LocalGatewayRoute("localGatewayRouteResource",
    destination_cidr_block="string",
    local_gateway_route_table_id="string",
    local_gateway_virtual_interface_group_id="string")
Copy
const localGatewayRouteResource = new aws.ec2.LocalGatewayRoute("localGatewayRouteResource", {
    destinationCidrBlock: "string",
    localGatewayRouteTableId: "string",
    localGatewayVirtualInterfaceGroupId: "string",
});
Copy
type: aws:ec2:LocalGatewayRoute
properties:
    destinationCidrBlock: string
    localGatewayRouteTableId: string
    localGatewayVirtualInterfaceGroupId: string
Copy

LocalGatewayRoute 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 LocalGatewayRoute resource accepts the following input properties:

DestinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
string
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
LocalGatewayRouteTableId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of EC2 Local Gateway Route Table.
LocalGatewayVirtualInterfaceGroupId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of EC2 Local Gateway Virtual Interface Group.
DestinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
string
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
LocalGatewayRouteTableId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of EC2 Local Gateway Route Table.
LocalGatewayVirtualInterfaceGroupId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of EC2 Local Gateway Virtual Interface Group.
destinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
String
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
localGatewayRouteTableId
This property is required.
Changes to this property will trigger replacement.
String
Identifier of EC2 Local Gateway Route Table.
localGatewayVirtualInterfaceGroupId
This property is required.
Changes to this property will trigger replacement.
String
Identifier of EC2 Local Gateway Virtual Interface Group.
destinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
string
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
localGatewayRouteTableId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of EC2 Local Gateway Route Table.
localGatewayVirtualInterfaceGroupId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of EC2 Local Gateway Virtual Interface Group.
destination_cidr_block
This property is required.
Changes to this property will trigger replacement.
str
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
local_gateway_route_table_id
This property is required.
Changes to this property will trigger replacement.
str
Identifier of EC2 Local Gateway Route Table.
local_gateway_virtual_interface_group_id
This property is required.
Changes to this property will trigger replacement.
str
Identifier of EC2 Local Gateway Virtual Interface Group.
destinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
String
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
localGatewayRouteTableId
This property is required.
Changes to this property will trigger replacement.
String
Identifier of EC2 Local Gateway Route Table.
localGatewayVirtualInterfaceGroupId
This property is required.
Changes to this property will trigger replacement.
String
Identifier of EC2 Local Gateway Virtual Interface Group.

Outputs

All input properties are implicitly available as output properties. Additionally, the LocalGatewayRoute 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 LocalGatewayRoute Resource

Get an existing LocalGatewayRoute 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?: LocalGatewayRouteState, opts?: CustomResourceOptions): LocalGatewayRoute
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        destination_cidr_block: Optional[str] = None,
        local_gateway_route_table_id: Optional[str] = None,
        local_gateway_virtual_interface_group_id: Optional[str] = None) -> LocalGatewayRoute
func GetLocalGatewayRoute(ctx *Context, name string, id IDInput, state *LocalGatewayRouteState, opts ...ResourceOption) (*LocalGatewayRoute, error)
public static LocalGatewayRoute Get(string name, Input<string> id, LocalGatewayRouteState? state, CustomResourceOptions? opts = null)
public static LocalGatewayRoute get(String name, Output<String> id, LocalGatewayRouteState state, CustomResourceOptions options)
resources:  _:    type: aws:ec2:LocalGatewayRoute    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
DestinationCidrBlock Changes to this property will trigger replacement. string
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
LocalGatewayRouteTableId Changes to this property will trigger replacement. string
Identifier of EC2 Local Gateway Route Table.
LocalGatewayVirtualInterfaceGroupId Changes to this property will trigger replacement. string
Identifier of EC2 Local Gateway Virtual Interface Group.
DestinationCidrBlock Changes to this property will trigger replacement. string
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
LocalGatewayRouteTableId Changes to this property will trigger replacement. string
Identifier of EC2 Local Gateway Route Table.
LocalGatewayVirtualInterfaceGroupId Changes to this property will trigger replacement. string
Identifier of EC2 Local Gateway Virtual Interface Group.
destinationCidrBlock Changes to this property will trigger replacement. String
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
localGatewayRouteTableId Changes to this property will trigger replacement. String
Identifier of EC2 Local Gateway Route Table.
localGatewayVirtualInterfaceGroupId Changes to this property will trigger replacement. String
Identifier of EC2 Local Gateway Virtual Interface Group.
destinationCidrBlock Changes to this property will trigger replacement. string
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
localGatewayRouteTableId Changes to this property will trigger replacement. string
Identifier of EC2 Local Gateway Route Table.
localGatewayVirtualInterfaceGroupId Changes to this property will trigger replacement. string
Identifier of EC2 Local Gateway Virtual Interface Group.
destination_cidr_block Changes to this property will trigger replacement. str
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
local_gateway_route_table_id Changes to this property will trigger replacement. str
Identifier of EC2 Local Gateway Route Table.
local_gateway_virtual_interface_group_id Changes to this property will trigger replacement. str
Identifier of EC2 Local Gateway Virtual Interface Group.
destinationCidrBlock Changes to this property will trigger replacement. String
IPv4 CIDR range used for destination matches. Routing decisions are based on the most specific match.
localGatewayRouteTableId Changes to this property will trigger replacement. String
Identifier of EC2 Local Gateway Route Table.
localGatewayVirtualInterfaceGroupId Changes to this property will trigger replacement. String
Identifier of EC2 Local Gateway Virtual Interface Group.

Import

Using pulumi import, import aws_ec2_local_gateway_route using the EC2 Local Gateway Route Table identifier and destination CIDR block separated by underscores (_). For example:

$ pulumi import aws:ec2/localGatewayRoute:LocalGatewayRoute example lgw-rtb-12345678_172.16.0.0/16
Copy

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

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.