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

aws.ec2.VpnConnectionRoute

Explore with Pulumi AI

Provides a static route between a VPN connection and a customer gateway.

Example Usage

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

const vpc = new aws.ec2.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
const vpnGateway = new aws.ec2.VpnGateway("vpn_gateway", {vpcId: vpc.id});
const customerGateway = new aws.ec2.CustomerGateway("customer_gateway", {
    bgpAsn: "65000",
    ipAddress: "172.0.0.1",
    type: "ipsec.1",
});
const main = new aws.ec2.VpnConnection("main", {
    vpnGatewayId: vpnGateway.id,
    customerGatewayId: customerGateway.id,
    type: "ipsec.1",
    staticRoutesOnly: true,
});
const office = new aws.ec2.VpnConnectionRoute("office", {
    destinationCidrBlock: "192.168.10.0/24",
    vpnConnectionId: main.id,
});
Copy
import pulumi
import pulumi_aws as aws

vpc = aws.ec2.Vpc("vpc", cidr_block="10.0.0.0/16")
vpn_gateway = aws.ec2.VpnGateway("vpn_gateway", vpc_id=vpc.id)
customer_gateway = aws.ec2.CustomerGateway("customer_gateway",
    bgp_asn="65000",
    ip_address="172.0.0.1",
    type="ipsec.1")
main = aws.ec2.VpnConnection("main",
    vpn_gateway_id=vpn_gateway.id,
    customer_gateway_id=customer_gateway.id,
    type="ipsec.1",
    static_routes_only=True)
office = aws.ec2.VpnConnectionRoute("office",
    destination_cidr_block="192.168.10.0/24",
    vpn_connection_id=main.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 {
		vpc, err := ec2.NewVpc(ctx, "vpc", &ec2.VpcArgs{
			CidrBlock: pulumi.String("10.0.0.0/16"),
		})
		if err != nil {
			return err
		}
		vpnGateway, err := ec2.NewVpnGateway(ctx, "vpn_gateway", &ec2.VpnGatewayArgs{
			VpcId: vpc.ID(),
		})
		if err != nil {
			return err
		}
		customerGateway, err := ec2.NewCustomerGateway(ctx, "customer_gateway", &ec2.CustomerGatewayArgs{
			BgpAsn:    pulumi.String("65000"),
			IpAddress: pulumi.String("172.0.0.1"),
			Type:      pulumi.String("ipsec.1"),
		})
		if err != nil {
			return err
		}
		main, err := ec2.NewVpnConnection(ctx, "main", &ec2.VpnConnectionArgs{
			VpnGatewayId:      vpnGateway.ID(),
			CustomerGatewayId: customerGateway.ID(),
			Type:              pulumi.String("ipsec.1"),
			StaticRoutesOnly:  pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = ec2.NewVpnConnectionRoute(ctx, "office", &ec2.VpnConnectionRouteArgs{
			DestinationCidrBlock: pulumi.String("192.168.10.0/24"),
			VpnConnectionId:      main.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 vpc = new Aws.Ec2.Vpc("vpc", new()
    {
        CidrBlock = "10.0.0.0/16",
    });

    var vpnGateway = new Aws.Ec2.VpnGateway("vpn_gateway", new()
    {
        VpcId = vpc.Id,
    });

    var customerGateway = new Aws.Ec2.CustomerGateway("customer_gateway", new()
    {
        BgpAsn = "65000",
        IpAddress = "172.0.0.1",
        Type = "ipsec.1",
    });

    var main = new Aws.Ec2.VpnConnection("main", new()
    {
        VpnGatewayId = vpnGateway.Id,
        CustomerGatewayId = customerGateway.Id,
        Type = "ipsec.1",
        StaticRoutesOnly = true,
    });

    var office = new Aws.Ec2.VpnConnectionRoute("office", new()
    {
        DestinationCidrBlock = "192.168.10.0/24",
        VpnConnectionId = main.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.ec2.VpnGateway;
import com.pulumi.aws.ec2.VpnGatewayArgs;
import com.pulumi.aws.ec2.CustomerGateway;
import com.pulumi.aws.ec2.CustomerGatewayArgs;
import com.pulumi.aws.ec2.VpnConnection;
import com.pulumi.aws.ec2.VpnConnectionArgs;
import com.pulumi.aws.ec2.VpnConnectionRoute;
import com.pulumi.aws.ec2.VpnConnectionRouteArgs;
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 vpc = new Vpc("vpc", VpcArgs.builder()
            .cidrBlock("10.0.0.0/16")
            .build());

        var vpnGateway = new VpnGateway("vpnGateway", VpnGatewayArgs.builder()
            .vpcId(vpc.id())
            .build());

        var customerGateway = new CustomerGateway("customerGateway", CustomerGatewayArgs.builder()
            .bgpAsn("65000")
            .ipAddress("172.0.0.1")
            .type("ipsec.1")
            .build());

        var main = new VpnConnection("main", VpnConnectionArgs.builder()
            .vpnGatewayId(vpnGateway.id())
            .customerGatewayId(customerGateway.id())
            .type("ipsec.1")
            .staticRoutesOnly(true)
            .build());

        var office = new VpnConnectionRoute("office", VpnConnectionRouteArgs.builder()
            .destinationCidrBlock("192.168.10.0/24")
            .vpnConnectionId(main.id())
            .build());

    }
}
Copy
resources:
  vpc:
    type: aws:ec2:Vpc
    properties:
      cidrBlock: 10.0.0.0/16
  vpnGateway:
    type: aws:ec2:VpnGateway
    name: vpn_gateway
    properties:
      vpcId: ${vpc.id}
  customerGateway:
    type: aws:ec2:CustomerGateway
    name: customer_gateway
    properties:
      bgpAsn: 65000
      ipAddress: 172.0.0.1
      type: ipsec.1
  main:
    type: aws:ec2:VpnConnection
    properties:
      vpnGatewayId: ${vpnGateway.id}
      customerGatewayId: ${customerGateway.id}
      type: ipsec.1
      staticRoutesOnly: true
  office:
    type: aws:ec2:VpnConnectionRoute
    properties:
      destinationCidrBlock: 192.168.10.0/24
      vpnConnectionId: ${main.id}
Copy

Create VpnConnectionRoute Resource

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

Constructor syntax

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

@overload
def VpnConnectionRoute(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       destination_cidr_block: Optional[str] = None,
                       vpn_connection_id: Optional[str] = None)
func NewVpnConnectionRoute(ctx *Context, name string, args VpnConnectionRouteArgs, opts ...ResourceOption) (*VpnConnectionRoute, error)
public VpnConnectionRoute(string name, VpnConnectionRouteArgs args, CustomResourceOptions? opts = null)
public VpnConnectionRoute(String name, VpnConnectionRouteArgs args)
public VpnConnectionRoute(String name, VpnConnectionRouteArgs args, CustomResourceOptions options)
type: aws:ec2:VpnConnectionRoute
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. VpnConnectionRouteArgs
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. VpnConnectionRouteInitArgs
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. VpnConnectionRouteArgs
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. VpnConnectionRouteArgs
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. VpnConnectionRouteArgs
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 vpnConnectionRouteResource = new Aws.Ec2.VpnConnectionRoute("vpnConnectionRouteResource", new()
{
    DestinationCidrBlock = "string",
    VpnConnectionId = "string",
});
Copy
example, err := ec2.NewVpnConnectionRoute(ctx, "vpnConnectionRouteResource", &ec2.VpnConnectionRouteArgs{
	DestinationCidrBlock: pulumi.String("string"),
	VpnConnectionId:      pulumi.String("string"),
})
Copy
var vpnConnectionRouteResource = new VpnConnectionRoute("vpnConnectionRouteResource", VpnConnectionRouteArgs.builder()
    .destinationCidrBlock("string")
    .vpnConnectionId("string")
    .build());
Copy
vpn_connection_route_resource = aws.ec2.VpnConnectionRoute("vpnConnectionRouteResource",
    destination_cidr_block="string",
    vpn_connection_id="string")
Copy
const vpnConnectionRouteResource = new aws.ec2.VpnConnectionRoute("vpnConnectionRouteResource", {
    destinationCidrBlock: "string",
    vpnConnectionId: "string",
});
Copy
type: aws:ec2:VpnConnectionRoute
properties:
    destinationCidrBlock: string
    vpnConnectionId: string
Copy

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

DestinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
string
The CIDR block associated with the local subnet of the customer network.
VpnConnectionId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the VPN connection.
DestinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
string
The CIDR block associated with the local subnet of the customer network.
VpnConnectionId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the VPN connection.
destinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
String
The CIDR block associated with the local subnet of the customer network.
vpnConnectionId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the VPN connection.
destinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
string
The CIDR block associated with the local subnet of the customer network.
vpnConnectionId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the VPN connection.
destination_cidr_block
This property is required.
Changes to this property will trigger replacement.
str
The CIDR block associated with the local subnet of the customer network.
vpn_connection_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the VPN connection.
destinationCidrBlock
This property is required.
Changes to this property will trigger replacement.
String
The CIDR block associated with the local subnet of the customer network.
vpnConnectionId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the VPN connection.

Outputs

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

Get an existing VpnConnectionRoute 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?: VpnConnectionRouteState, opts?: CustomResourceOptions): VpnConnectionRoute
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        destination_cidr_block: Optional[str] = None,
        vpn_connection_id: Optional[str] = None) -> VpnConnectionRoute
func GetVpnConnectionRoute(ctx *Context, name string, id IDInput, state *VpnConnectionRouteState, opts ...ResourceOption) (*VpnConnectionRoute, error)
public static VpnConnectionRoute Get(string name, Input<string> id, VpnConnectionRouteState? state, CustomResourceOptions? opts = null)
public static VpnConnectionRoute get(String name, Output<String> id, VpnConnectionRouteState state, CustomResourceOptions options)
resources:  _:    type: aws:ec2:VpnConnectionRoute    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
The CIDR block associated with the local subnet of the customer network.
VpnConnectionId Changes to this property will trigger replacement. string
The ID of the VPN connection.
DestinationCidrBlock Changes to this property will trigger replacement. string
The CIDR block associated with the local subnet of the customer network.
VpnConnectionId Changes to this property will trigger replacement. string
The ID of the VPN connection.
destinationCidrBlock Changes to this property will trigger replacement. String
The CIDR block associated with the local subnet of the customer network.
vpnConnectionId Changes to this property will trigger replacement. String
The ID of the VPN connection.
destinationCidrBlock Changes to this property will trigger replacement. string
The CIDR block associated with the local subnet of the customer network.
vpnConnectionId Changes to this property will trigger replacement. string
The ID of the VPN connection.
destination_cidr_block Changes to this property will trigger replacement. str
The CIDR block associated with the local subnet of the customer network.
vpn_connection_id Changes to this property will trigger replacement. str
The ID of the VPN connection.
destinationCidrBlock Changes to this property will trigger replacement. String
The CIDR block associated with the local subnet of the customer network.
vpnConnectionId Changes to this property will trigger replacement. String
The ID of the VPN connection.

Package Details

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