1. Packages
  2. AWS
  3. API Docs
  4. ec2transitgateway
  5. getVpnAttachment
AWS v6.78.0 published on Thursday, Apr 24, 2025 by Pulumi

aws.ec2transitgateway.getVpnAttachment

Explore with Pulumi AI

Get information on an EC2 Transit Gateway VPN Attachment.

EC2 Transit Gateway VPN Attachments are implicitly created by VPN Connections referencing an EC2 Transit Gateway so there is no managed resource. For ease, the aws.ec2.VpnConnection resource includes a transit_gateway_attachment_id attribute which can replace some usage of this data source. For tagging the attachment, see the aws.ec2.Tag resource.

Example Usage

By Transit Gateway and VPN Connection Identifiers

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

const example = aws.ec2transitgateway.getVpnAttachment({
    transitGatewayId: exampleAwsEc2TransitGateway.id,
    vpnConnectionId: exampleAwsVpnConnection.id,
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.ec2transitgateway.get_vpn_attachment(transit_gateway_id=example_aws_ec2_transit_gateway["id"],
    vpn_connection_id=example_aws_vpn_connection["id"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2transitgateway.GetVpnAttachment(ctx, &ec2transitgateway.GetVpnAttachmentArgs{
			TransitGatewayId: pulumi.StringRef(exampleAwsEc2TransitGateway.Id),
			VpnConnectionId:  pulumi.StringRef(exampleAwsVpnConnection.Id),
		}, nil)
		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 = Aws.Ec2TransitGateway.GetVpnAttachment.Invoke(new()
    {
        TransitGatewayId = exampleAwsEc2TransitGateway.Id,
        VpnConnectionId = exampleAwsVpnConnection.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2transitgateway.Ec2transitgatewayFunctions;
import com.pulumi.aws.ec2transitgateway.inputs.GetVpnAttachmentArgs;
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 = Ec2transitgatewayFunctions.getVpnAttachment(GetVpnAttachmentArgs.builder()
            .transitGatewayId(exampleAwsEc2TransitGateway.id())
            .vpnConnectionId(exampleAwsVpnConnection.id())
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: aws:ec2transitgateway:getVpnAttachment
      arguments:
        transitGatewayId: ${exampleAwsEc2TransitGateway.id}
        vpnConnectionId: ${exampleAwsVpnConnection.id}
Copy

Filter

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

const test = aws.ec2transitgateway.getVpnAttachment({
    filters: [{
        name: "resource-id",
        values: ["some-resource"],
    }],
});
Copy
import pulumi
import pulumi_aws as aws

test = aws.ec2transitgateway.get_vpn_attachment(filters=[{
    "name": "resource-id",
    "values": ["some-resource"],
}])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2transitgateway.GetVpnAttachment(ctx, &ec2transitgateway.GetVpnAttachmentArgs{
			Filters: []ec2transitgateway.GetVpnAttachmentFilter{
				{
					Name: "resource-id",
					Values: []string{
						"some-resource",
					},
				},
			},
		}, nil)
		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 test = Aws.Ec2TransitGateway.GetVpnAttachment.Invoke(new()
    {
        Filters = new[]
        {
            new Aws.Ec2TransitGateway.Inputs.GetVpnAttachmentFilterInputArgs
            {
                Name = "resource-id",
                Values = new[]
                {
                    "some-resource",
                },
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2transitgateway.Ec2transitgatewayFunctions;
import com.pulumi.aws.ec2transitgateway.inputs.GetVpnAttachmentArgs;
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 test = Ec2transitgatewayFunctions.getVpnAttachment(GetVpnAttachmentArgs.builder()
            .filters(GetVpnAttachmentFilterArgs.builder()
                .name("resource-id")
                .values("some-resource")
                .build())
            .build());

    }
}
Copy
variables:
  test:
    fn::invoke:
      function: aws:ec2transitgateway:getVpnAttachment
      arguments:
        filters:
          - name: resource-id
            values:
              - some-resource
Copy

Using getVpnAttachment

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 getVpnAttachment(args: GetVpnAttachmentArgs, opts?: InvokeOptions): Promise<GetVpnAttachmentResult>
function getVpnAttachmentOutput(args: GetVpnAttachmentOutputArgs, opts?: InvokeOptions): Output<GetVpnAttachmentResult>
Copy
def get_vpn_attachment(filters: Optional[Sequence[GetVpnAttachmentFilter]] = None,
                       tags: Optional[Mapping[str, str]] = None,
                       transit_gateway_id: Optional[str] = None,
                       vpn_connection_id: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetVpnAttachmentResult
def get_vpn_attachment_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetVpnAttachmentFilterArgs]]]] = None,
                       tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                       transit_gateway_id: Optional[pulumi.Input[str]] = None,
                       vpn_connection_id: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetVpnAttachmentResult]
Copy
func GetVpnAttachment(ctx *Context, args *GetVpnAttachmentArgs, opts ...InvokeOption) (*GetVpnAttachmentResult, error)
func GetVpnAttachmentOutput(ctx *Context, args *GetVpnAttachmentOutputArgs, opts ...InvokeOption) GetVpnAttachmentResultOutput
Copy

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

public static class GetVpnAttachment 
{
    public static Task<GetVpnAttachmentResult> InvokeAsync(GetVpnAttachmentArgs args, InvokeOptions? opts = null)
    public static Output<GetVpnAttachmentResult> Invoke(GetVpnAttachmentInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetVpnAttachmentResult> getVpnAttachment(GetVpnAttachmentArgs args, InvokeOptions options)
public static Output<GetVpnAttachmentResult> getVpnAttachment(GetVpnAttachmentArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: aws:ec2transitgateway/getVpnAttachment:getVpnAttachment
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<GetVpnAttachmentFilter>
Configuration block(s) for filtering. Detailed below.
Tags Dictionary<string, string>
Map of tags, each pair of which must exactly match a pair on the desired Transit Gateway VPN Attachment.
TransitGatewayId string
Identifier of the EC2 Transit Gateway.
VpnConnectionId string
Identifier of the EC2 VPN Connection.
Filters []GetVpnAttachmentFilter
Configuration block(s) for filtering. Detailed below.
Tags map[string]string
Map of tags, each pair of which must exactly match a pair on the desired Transit Gateway VPN Attachment.
TransitGatewayId string
Identifier of the EC2 Transit Gateway.
VpnConnectionId string
Identifier of the EC2 VPN Connection.
filters List<GetVpnAttachmentFilter>
Configuration block(s) for filtering. Detailed below.
tags Map<String,String>
Map of tags, each pair of which must exactly match a pair on the desired Transit Gateway VPN Attachment.
transitGatewayId String
Identifier of the EC2 Transit Gateway.
vpnConnectionId String
Identifier of the EC2 VPN Connection.
filters GetVpnAttachmentFilter[]
Configuration block(s) for filtering. Detailed below.
tags {[key: string]: string}
Map of tags, each pair of which must exactly match a pair on the desired Transit Gateway VPN Attachment.
transitGatewayId string
Identifier of the EC2 Transit Gateway.
vpnConnectionId string
Identifier of the EC2 VPN Connection.
filters Sequence[GetVpnAttachmentFilter]
Configuration block(s) for filtering. Detailed below.
tags Mapping[str, str]
Map of tags, each pair of which must exactly match a pair on the desired Transit Gateway VPN Attachment.
transit_gateway_id str
Identifier of the EC2 Transit Gateway.
vpn_connection_id str
Identifier of the EC2 VPN Connection.
filters List<Property Map>
Configuration block(s) for filtering. Detailed below.
tags Map<String>
Map of tags, each pair of which must exactly match a pair on the desired Transit Gateway VPN Attachment.
transitGatewayId String
Identifier of the EC2 Transit Gateway.
vpnConnectionId String
Identifier of the EC2 VPN Connection.

getVpnAttachment Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Tags Dictionary<string, string>
Key-value tags for the EC2 Transit Gateway VPN Attachment
Filters List<GetVpnAttachmentFilter>
TransitGatewayId string
VpnConnectionId string
Id string
The provider-assigned unique ID for this managed resource.
Tags map[string]string
Key-value tags for the EC2 Transit Gateway VPN Attachment
Filters []GetVpnAttachmentFilter
TransitGatewayId string
VpnConnectionId string
id String
The provider-assigned unique ID for this managed resource.
tags Map<String,String>
Key-value tags for the EC2 Transit Gateway VPN Attachment
filters List<GetVpnAttachmentFilter>
transitGatewayId String
vpnConnectionId String
id string
The provider-assigned unique ID for this managed resource.
tags {[key: string]: string}
Key-value tags for the EC2 Transit Gateway VPN Attachment
filters GetVpnAttachmentFilter[]
transitGatewayId string
vpnConnectionId string
id str
The provider-assigned unique ID for this managed resource.
tags Mapping[str, str]
Key-value tags for the EC2 Transit Gateway VPN Attachment
filters Sequence[GetVpnAttachmentFilter]
transit_gateway_id str
vpn_connection_id str
id String
The provider-assigned unique ID for this managed resource.
tags Map<String>
Key-value tags for the EC2 Transit Gateway VPN Attachment
filters List<Property Map>
transitGatewayId String
vpnConnectionId String

Supporting Types

GetVpnAttachmentFilter

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

Package Details

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