AWS::EC2::VPCGatewayAttachment - AWS CloudFormation

AWS::EC2::VPCGatewayAttachment

Attaches an internet gateway, or a virtual private gateway to a VPC, enabling connectivity between the internet and the VPC.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::EC2::VPCGatewayAttachment", "Properties" : { "InternetGatewayId" : String, "VpcId" : String, "VpnGatewayId" : String } }

YAML

Type: AWS::EC2::VPCGatewayAttachment Properties: InternetGatewayId: String VpcId: String VpnGatewayId: String

Properties

InternetGatewayId

The ID of the internet gateway.

You must specify either InternetGatewayId or VpnGatewayId, but not both.

Required: No

Type: String

Update requires: No interruption

VpcId

The ID of the VPC.

Required: Yes

Type: String

Update requires: Replacement

VpnGatewayId

The ID of the virtual private gateway.

You must specify either InternetGatewayId or VpnGatewayId, but not both.

Required: No

Type: String

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the ID of the VPC gateway attachment.

For more information about using the Ref function, see Ref.

Examples

VPN gateway attachment

To attach both an Internet gateway and a VPN gateway to a VPC, you must specify two separate AWS::EC2::VPCGatewayAttachment resources:

JSON

"AttachGateway" : { "Type" : "AWS::EC2::VPCGatewayAttachment", "Properties" : { "VpcId" : { "Ref" : "VPC" }, "InternetGatewayId" : { "Ref" : "myInternetGateway" } } }, "AttachVpnGateway" : { "Type" : "AWS::EC2::VPCGatewayAttachment", "Properties" : { "VpcId" : { "Ref" : "VPC" }, "VpnGatewayId" : { "Ref" : "myVPNGateway" } } }

YAML

AttachGateway: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: Ref: VPC InternetGatewayId: Ref: myInternetGateway AttachVpnGateway: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: Ref: VPC VpnGatewayId: Ref: myVPNGateway

See also