1. Packages
  2. AWS
  3. API Docs
  4. vpn
  5. getConnection
AWS v7.9.0 published on Tuesday, Oct 21, 2025 by Pulumi

aws.vpn.getConnection

Get Started
aws logo
AWS v7.9.0 published on Tuesday, Oct 21, 2025 by Pulumi
    Deprecated: aws.vpn/getconnection.getConnection has been deprecated in favor of aws.ec2/getvpnconnection.getVpnConnection

    Fetches details of a Site-to-Site VPN connection. A Site-to-Site VPN connection is an Internet Protocol security (IPsec) VPN connection between a VPC and an on-premises network.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.ec2.getVpnConnection({
        filters: [{
            name: "customer-gateway-id",
            values: ["cgw-1234567890"],
        }],
    });
    export const vpnConnectionId = example.then(example => example.vpnConnectionId);
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.get_vpn_connection(filters=[{
        "name": "customer-gateway-id",
        "values": ["cgw-1234567890"],
    }])
    pulumi.export("vpnConnectionId", example.vpn_connection_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ec2.LookupVpnConnection(ctx, &ec2.LookupVpnConnectionArgs{
    			Filters: []ec2.GetVpnConnectionFilter{
    				{
    					Name: "customer-gateway-id",
    					Values: []string{
    						"cgw-1234567890",
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("vpnConnectionId", example.VpnConnectionId)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetVpnConnection.Invoke(new()
        {
            Filters = new[]
            {
                new Aws.Ec2.Inputs.GetVpnConnectionFilterInputArgs
                {
                    Name = "customer-gateway-id",
                    Values = new[]
                    {
                        "cgw-1234567890",
                    },
                },
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["vpnConnectionId"] = example.Apply(getVpnConnectionResult => getVpnConnectionResult.VpnConnectionId),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetVpnConnectionArgs;
    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) {
            final var example = Ec2Functions.getVpnConnection(GetVpnConnectionArgs.builder()
                .filters(GetVpnConnectionFilterArgs.builder()
                    .name("customer-gateway-id")
                    .values("cgw-1234567890")
                    .build())
                .build());
    
            ctx.export("vpnConnectionId", example.vpnConnectionId());
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: aws:ec2:getVpnConnection
          arguments:
            filters:
              - name: customer-gateway-id
                values:
                  - cgw-1234567890
    outputs:
      vpnConnectionId: ${example.vpnConnectionId}
    

    Find by VPN Connection ID

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.ec2.getVpnConnection({
        vpnConnectionId: "vpn-abcd1234567890",
    });
    export const gatewayAssociationState = example.then(example => example.gatewayAssociationState);
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.get_vpn_connection(vpn_connection_id="vpn-abcd1234567890")
    pulumi.export("gatewayAssociationState", example.gateway_association_state)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ec2.LookupVpnConnection(ctx, &ec2.LookupVpnConnectionArgs{
    			VpnConnectionId: pulumi.StringRef("vpn-abcd1234567890"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("gatewayAssociationState", example.GatewayAssociationState)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetVpnConnection.Invoke(new()
        {
            VpnConnectionId = "vpn-abcd1234567890",
        });
    
        return new Dictionary<string, object?>
        {
            ["gatewayAssociationState"] = example.Apply(getVpnConnectionResult => getVpnConnectionResult.GatewayAssociationState),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetVpnConnectionArgs;
    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) {
            final var example = Ec2Functions.getVpnConnection(GetVpnConnectionArgs.builder()
                .vpnConnectionId("vpn-abcd1234567890")
                .build());
    
            ctx.export("gatewayAssociationState", example.gatewayAssociationState());
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: aws:ec2:getVpnConnection
          arguments:
            vpnConnectionId: vpn-abcd1234567890
    outputs:
      gatewayAssociationState: ${example.gatewayAssociationState}
    

    Using getConnection

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getConnection(args: GetConnectionArgs, opts?: InvokeOptions): Promise<GetConnectionResult>
    function getConnectionOutput(args: GetConnectionOutputArgs, opts?: InvokeOptions): Output<GetConnectionResult>
    def get_connection(filters: Optional[Sequence[GetConnectionFilter]] = None,
                       region: Optional[str] = None,
                       vpn_connection_id: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetConnectionResult
    def get_connection_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetConnectionFilterArgs]]]] = None,
                       region: Optional[pulumi.Input[str]] = None,
                       vpn_connection_id: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetConnectionResult]
    func GetConnection(ctx *Context, args *GetConnectionArgs, opts ...InvokeOption) (*GetConnectionResult, error)
    func GetConnectionOutput(ctx *Context, args *GetConnectionOutputArgs, opts ...InvokeOption) GetConnectionResultOutput

    > Note: This function is named GetConnection in the Go SDK.

    public static class GetConnection 
    {
        public static Task<GetConnectionResult> InvokeAsync(GetConnectionArgs args, InvokeOptions? opts = null)
        public static Output<GetConnectionResult> Invoke(GetConnectionInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetConnectionResult> getConnection(GetConnectionArgs args, InvokeOptions options)
    public static Output<GetConnectionResult> getConnection(GetConnectionArgs args, InvokeOptions options)
    
    fn::invoke:
      function: aws:vpn/getConnection:getConnection
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filters List<GetConnectionFilter>
    Configuration block(s) for filtering. Detailed below.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    VpnConnectionId string
    Identifier of the EC2 VPN Connection.
    Filters []GetConnectionFilter
    Configuration block(s) for filtering. Detailed below.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    VpnConnectionId string
    Identifier of the EC2 VPN Connection.
    filters List<GetConnectionFilter>
    Configuration block(s) for filtering. Detailed below.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    vpnConnectionId String
    Identifier of the EC2 VPN Connection.
    filters GetConnectionFilter[]
    Configuration block(s) for filtering. Detailed below.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    vpnConnectionId string
    Identifier of the EC2 VPN Connection.
    filters Sequence[GetConnectionFilter]
    Configuration block(s) for filtering. Detailed below.
    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    vpn_connection_id str
    Identifier of the EC2 VPN Connection.
    filters List<Property Map>
    Configuration block(s) for filtering. Detailed below.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    vpnConnectionId String
    Identifier of the EC2 VPN Connection.

    getConnection Result

    The following output properties are available:

    Category string
    Category of the VPN connection. A value of VPN indicates an AWS VPN connection. A value of VPN-Classic indicates an AWS Classic VPN connection.
    CoreNetworkArn string
    ARN of the core network.
    CoreNetworkAttachmentArn string
    ARN of the core network attachment.
    CustomerGatewayConfiguration string
    Configuration information for the VPN connection's customer gateway (in the native XML format).
    CustomerGatewayId string
    ID of the customer gateway at your end of the VPN connection.
    GatewayAssociationState string
    Current state of the gateway association.
    Id string
    The provider-assigned unique ID for this managed resource.
    PreSharedKeyArn string
    (ARN) of the Secrets Manager secret storing the pre-shared key(s) for the VPN connection.
    Region string
    Routes List<GetConnectionRoute>
    List of static routes associated with the VPN connection.
    State string
    Current state of the VPN connection.
    Tags Dictionary<string, string>
    Tags associated to the VPN Connection.
    TransitGatewayId string
    ID of a transit gateway associated with the VPN connection.
    Type string
    Type of VPN connection. Currently the only supported type is ipsec.1.
    VgwTelemetries List<GetConnectionVgwTelemetry>
    List of objects containing information about the VPN tunnel.
    VpnConnectionId string
    VpnGatewayId string
    ID of a virtual private gateway associated with the VPN connection.
    Filters List<GetConnectionFilter>
    Category string
    Category of the VPN connection. A value of VPN indicates an AWS VPN connection. A value of VPN-Classic indicates an AWS Classic VPN connection.
    CoreNetworkArn string
    ARN of the core network.
    CoreNetworkAttachmentArn string
    ARN of the core network attachment.
    CustomerGatewayConfiguration string
    Configuration information for the VPN connection's customer gateway (in the native XML format).
    CustomerGatewayId string
    ID of the customer gateway at your end of the VPN connection.
    GatewayAssociationState string
    Current state of the gateway association.
    Id string
    The provider-assigned unique ID for this managed resource.
    PreSharedKeyArn string
    (ARN) of the Secrets Manager secret storing the pre-shared key(s) for the VPN connection.
    Region string
    Routes []GetConnectionRoute
    List of static routes associated with the VPN connection.
    State string
    Current state of the VPN connection.
    Tags map[string]string
    Tags associated to the VPN Connection.
    TransitGatewayId string
    ID of a transit gateway associated with the VPN connection.
    Type string
    Type of VPN connection. Currently the only supported type is ipsec.1.
    VgwTelemetries []GetConnectionVgwTelemetry
    List of objects containing information about the VPN tunnel.
    VpnConnectionId string
    VpnGatewayId string
    ID of a virtual private gateway associated with the VPN connection.
    Filters []GetConnectionFilter
    category String
    Category of the VPN connection. A value of VPN indicates an AWS VPN connection. A value of VPN-Classic indicates an AWS Classic VPN connection.
    coreNetworkArn String
    ARN of the core network.
    coreNetworkAttachmentArn String
    ARN of the core network attachment.
    customerGatewayConfiguration String
    Configuration information for the VPN connection's customer gateway (in the native XML format).
    customerGatewayId String
    ID of the customer gateway at your end of the VPN connection.
    gatewayAssociationState String
    Current state of the gateway association.
    id String
    The provider-assigned unique ID for this managed resource.
    preSharedKeyArn String
    (ARN) of the Secrets Manager secret storing the pre-shared key(s) for the VPN connection.
    region String
    routes List<GetConnectionRoute>
    List of static routes associated with the VPN connection.
    state String
    Current state of the VPN connection.
    tags Map<String,String>
    Tags associated to the VPN Connection.
    transitGatewayId String
    ID of a transit gateway associated with the VPN connection.
    type String
    Type of VPN connection. Currently the only supported type is ipsec.1.
    vgwTelemetries List<GetConnectionVgwTelemetry>
    List of objects containing information about the VPN tunnel.
    vpnConnectionId String
    vpnGatewayId String
    ID of a virtual private gateway associated with the VPN connection.
    filters List<GetConnectionFilter>
    category string
    Category of the VPN connection. A value of VPN indicates an AWS VPN connection. A value of VPN-Classic indicates an AWS Classic VPN connection.
    coreNetworkArn string
    ARN of the core network.
    coreNetworkAttachmentArn string
    ARN of the core network attachment.
    customerGatewayConfiguration string
    Configuration information for the VPN connection's customer gateway (in the native XML format).
    customerGatewayId string
    ID of the customer gateway at your end of the VPN connection.
    gatewayAssociationState string
    Current state of the gateway association.
    id string
    The provider-assigned unique ID for this managed resource.
    preSharedKeyArn string
    (ARN) of the Secrets Manager secret storing the pre-shared key(s) for the VPN connection.
    region string
    routes GetConnectionRoute[]
    List of static routes associated with the VPN connection.
    state string
    Current state of the VPN connection.
    tags {[key: string]: string}
    Tags associated to the VPN Connection.
    transitGatewayId string
    ID of a transit gateway associated with the VPN connection.
    type string
    Type of VPN connection. Currently the only supported type is ipsec.1.
    vgwTelemetries GetConnectionVgwTelemetry[]
    List of objects containing information about the VPN tunnel.
    vpnConnectionId string
    vpnGatewayId string
    ID of a virtual private gateway associated with the VPN connection.
    filters GetConnectionFilter[]
    category str
    Category of the VPN connection. A value of VPN indicates an AWS VPN connection. A value of VPN-Classic indicates an AWS Classic VPN connection.
    core_network_arn str
    ARN of the core network.
    core_network_attachment_arn str
    ARN of the core network attachment.
    customer_gateway_configuration str
    Configuration information for the VPN connection's customer gateway (in the native XML format).
    customer_gateway_id str
    ID of the customer gateway at your end of the VPN connection.
    gateway_association_state str
    Current state of the gateway association.
    id str
    The provider-assigned unique ID for this managed resource.
    pre_shared_key_arn str
    (ARN) of the Secrets Manager secret storing the pre-shared key(s) for the VPN connection.
    region str
    routes Sequence[GetConnectionRoute]
    List of static routes associated with the VPN connection.
    state str
    Current state of the VPN connection.
    tags Mapping[str, str]
    Tags associated to the VPN Connection.
    transit_gateway_id str
    ID of a transit gateway associated with the VPN connection.
    type str
    Type of VPN connection. Currently the only supported type is ipsec.1.
    vgw_telemetries Sequence[GetConnectionVgwTelemetry]
    List of objects containing information about the VPN tunnel.
    vpn_connection_id str
    vpn_gateway_id str
    ID of a virtual private gateway associated with the VPN connection.
    filters Sequence[GetConnectionFilter]
    category String
    Category of the VPN connection. A value of VPN indicates an AWS VPN connection. A value of VPN-Classic indicates an AWS Classic VPN connection.
    coreNetworkArn String
    ARN of the core network.
    coreNetworkAttachmentArn String
    ARN of the core network attachment.
    customerGatewayConfiguration String
    Configuration information for the VPN connection's customer gateway (in the native XML format).
    customerGatewayId String
    ID of the customer gateway at your end of the VPN connection.
    gatewayAssociationState String
    Current state of the gateway association.
    id String
    The provider-assigned unique ID for this managed resource.
    preSharedKeyArn String
    (ARN) of the Secrets Manager secret storing the pre-shared key(s) for the VPN connection.
    region String
    routes List<Property Map>
    List of static routes associated with the VPN connection.
    state String
    Current state of the VPN connection.
    tags Map<String>
    Tags associated to the VPN Connection.
    transitGatewayId String
    ID of a transit gateway associated with the VPN connection.
    type String
    Type of VPN connection. Currently the only supported type is ipsec.1.
    vgwTelemetries List<Property Map>
    List of objects containing information about the VPN tunnel.
    vpnConnectionId String
    vpnGatewayId String
    ID of a virtual private gateway associated with the VPN connection.
    filters List<Property Map>

    Supporting Types

    GetConnectionFilter

    Name string
    Name of the filter field. Valid values can be found in the EC2 DescribeVPNConnections API Reference.
    Values List<string>
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    Name string
    Name of the filter field. Valid values can be found in the EC2 DescribeVPNConnections API Reference.
    Values []string
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name String
    Name of the filter field. Valid values can be found in the EC2 DescribeVPNConnections API Reference.
    values List<String>
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name string
    Name of the filter field. Valid values can be found in the EC2 DescribeVPNConnections API Reference.
    values string[]
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name str
    Name of the filter field. Valid values can be found in the EC2 DescribeVPNConnections API Reference.
    values Sequence[str]
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name String
    Name of the filter field. Valid values can be found in the EC2 DescribeVPNConnections API Reference.
    values List<String>
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.

    GetConnectionRoute

    DestinationCidrBlock string
    Source string
    State string
    Current state of the VPN connection.
    DestinationCidrBlock string
    Source string
    State string
    Current state of the VPN connection.
    destinationCidrBlock String
    source String
    state String
    Current state of the VPN connection.
    destinationCidrBlock string
    source string
    state string
    Current state of the VPN connection.
    destination_cidr_block str
    source str
    state str
    Current state of the VPN connection.
    destinationCidrBlock String
    source String
    state String
    Current state of the VPN connection.

    GetConnectionVgwTelemetry

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v7.9.0 published on Tuesday, Oct 21, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate