1. Packages
  2. AWS Classic
  3. API Docs
  4. ec2
  5. VpnGatewayAttachment

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.ec2.VpnGatewayAttachment

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    Provides a Virtual Private Gateway attachment resource, allowing for an existing hardware VPN gateway to be attached and/or detached from a VPC.

    Note: The aws.ec2.VpnGateway resource can also automatically attach the Virtual Private Gateway it creates to an existing VPC by setting the vpc_id attribute accordingly.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const network = new aws.ec2.Vpc("network", {cidrBlock: "10.0.0.0/16"});
    const vpn = new aws.ec2.VpnGateway("vpn", {tags: {
        Name: "example-vpn-gateway",
    }});
    const vpnAttachment = new aws.ec2.VpnGatewayAttachment("vpn_attachment", {
        vpcId: network.id,
        vpnGatewayId: vpn.id,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    network = aws.ec2.Vpc("network", cidr_block="10.0.0.0/16")
    vpn = aws.ec2.VpnGateway("vpn", tags={
        "Name": "example-vpn-gateway",
    })
    vpn_attachment = aws.ec2.VpnGatewayAttachment("vpn_attachment",
        vpc_id=network.id,
        vpn_gateway_id=vpn.id)
    
    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 {
    		network, err := ec2.NewVpc(ctx, "network", &ec2.VpcArgs{
    			CidrBlock: pulumi.String("10.0.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		vpn, err := ec2.NewVpnGateway(ctx, "vpn", &ec2.VpnGatewayArgs{
    			Tags: pulumi.StringMap{
    				"Name": pulumi.String("example-vpn-gateway"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ec2.NewVpnGatewayAttachment(ctx, "vpn_attachment", &ec2.VpnGatewayAttachmentArgs{
    			VpcId:        network.ID(),
    			VpnGatewayId: vpn.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var network = new Aws.Ec2.Vpc("network", new()
        {
            CidrBlock = "10.0.0.0/16",
        });
    
        var vpn = new Aws.Ec2.VpnGateway("vpn", new()
        {
            Tags = 
            {
                { "Name", "example-vpn-gateway" },
            },
        });
    
        var vpnAttachment = new Aws.Ec2.VpnGatewayAttachment("vpn_attachment", new()
        {
            VpcId = network.Id,
            VpnGatewayId = vpn.Id,
        });
    
    });
    
    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.VpnGatewayAttachment;
    import com.pulumi.aws.ec2.VpnGatewayAttachmentArgs;
    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 network = new Vpc("network", VpcArgs.builder()
                .cidrBlock("10.0.0.0/16")
                .build());
    
            var vpn = new VpnGateway("vpn", VpnGatewayArgs.builder()
                .tags(Map.of("Name", "example-vpn-gateway"))
                .build());
    
            var vpnAttachment = new VpnGatewayAttachment("vpnAttachment", VpnGatewayAttachmentArgs.builder()
                .vpcId(network.id())
                .vpnGatewayId(vpn.id())
                .build());
    
        }
    }
    
    resources:
      network:
        type: aws:ec2:Vpc
        properties:
          cidrBlock: 10.0.0.0/16
      vpn:
        type: aws:ec2:VpnGateway
        properties:
          tags:
            Name: example-vpn-gateway
      vpnAttachment:
        type: aws:ec2:VpnGatewayAttachment
        name: vpn_attachment
        properties:
          vpcId: ${network.id}
          vpnGatewayId: ${vpn.id}
    

    See Virtual Private Cloud and Virtual Private Gateway user guides for more information.

    Create VpnGatewayAttachment Resource

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

    Constructor syntax

    new VpnGatewayAttachment(name: string, args: VpnGatewayAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def VpnGatewayAttachment(resource_name: str,
                             args: VpnGatewayAttachmentArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def VpnGatewayAttachment(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             vpc_id: Optional[str] = None,
                             vpn_gateway_id: Optional[str] = None)
    func NewVpnGatewayAttachment(ctx *Context, name string, args VpnGatewayAttachmentArgs, opts ...ResourceOption) (*VpnGatewayAttachment, error)
    public VpnGatewayAttachment(string name, VpnGatewayAttachmentArgs args, CustomResourceOptions? opts = null)
    public VpnGatewayAttachment(String name, VpnGatewayAttachmentArgs args)
    public VpnGatewayAttachment(String name, VpnGatewayAttachmentArgs args, CustomResourceOptions options)
    
    type: aws:ec2:VpnGatewayAttachment
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args VpnGatewayAttachmentArgs
    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 VpnGatewayAttachmentArgs
    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 VpnGatewayAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VpnGatewayAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VpnGatewayAttachmentArgs
    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 vpnGatewayAttachmentResource = new Aws.Ec2.VpnGatewayAttachment("vpnGatewayAttachmentResource", new()
    {
        VpcId = "string",
        VpnGatewayId = "string",
    });
    
    example, err := ec2.NewVpnGatewayAttachment(ctx, "vpnGatewayAttachmentResource", &ec2.VpnGatewayAttachmentArgs{
    	VpcId:        pulumi.String("string"),
    	VpnGatewayId: pulumi.String("string"),
    })
    
    var vpnGatewayAttachmentResource = new VpnGatewayAttachment("vpnGatewayAttachmentResource", VpnGatewayAttachmentArgs.builder()
        .vpcId("string")
        .vpnGatewayId("string")
        .build());
    
    vpn_gateway_attachment_resource = aws.ec2.VpnGatewayAttachment("vpnGatewayAttachmentResource",
        vpc_id="string",
        vpn_gateway_id="string")
    
    const vpnGatewayAttachmentResource = new aws.ec2.VpnGatewayAttachment("vpnGatewayAttachmentResource", {
        vpcId: "string",
        vpnGatewayId: "string",
    });
    
    type: aws:ec2:VpnGatewayAttachment
    properties:
        vpcId: string
        vpnGatewayId: string
    

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

    VpcId string
    The ID of the VPC.
    VpnGatewayId string
    The ID of the Virtual Private Gateway.
    VpcId string
    The ID of the VPC.
    VpnGatewayId string
    The ID of the Virtual Private Gateway.
    vpcId String
    The ID of the VPC.
    vpnGatewayId String
    The ID of the Virtual Private Gateway.
    vpcId string
    The ID of the VPC.
    vpnGatewayId string
    The ID of the Virtual Private Gateway.
    vpc_id str
    The ID of the VPC.
    vpn_gateway_id str
    The ID of the Virtual Private Gateway.
    vpcId String
    The ID of the VPC.
    vpnGatewayId String
    The ID of the Virtual Private Gateway.

    Outputs

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

    Get an existing VpnGatewayAttachment 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?: VpnGatewayAttachmentState, opts?: CustomResourceOptions): VpnGatewayAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            vpc_id: Optional[str] = None,
            vpn_gateway_id: Optional[str] = None) -> VpnGatewayAttachment
    func GetVpnGatewayAttachment(ctx *Context, name string, id IDInput, state *VpnGatewayAttachmentState, opts ...ResourceOption) (*VpnGatewayAttachment, error)
    public static VpnGatewayAttachment Get(string name, Input<string> id, VpnGatewayAttachmentState? state, CustomResourceOptions? opts = null)
    public static VpnGatewayAttachment get(String name, Output<String> id, VpnGatewayAttachmentState 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:
    VpcId string
    The ID of the VPC.
    VpnGatewayId string
    The ID of the Virtual Private Gateway.
    VpcId string
    The ID of the VPC.
    VpnGatewayId string
    The ID of the Virtual Private Gateway.
    vpcId String
    The ID of the VPC.
    vpnGatewayId String
    The ID of the Virtual Private Gateway.
    vpcId string
    The ID of the VPC.
    vpnGatewayId string
    The ID of the Virtual Private Gateway.
    vpc_id str
    The ID of the VPC.
    vpn_gateway_id str
    The ID of the Virtual Private Gateway.
    vpcId String
    The ID of the VPC.
    vpnGatewayId String
    The ID of the Virtual Private Gateway.

    Import

    You cannot import this resource.

    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.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi