This is the new *CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html). # 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 CloudFormation template, use the following syntax: ### JSON ``` { "Type" : "AWS::EC2::VPCGatewayAttachment", "Properties" : { "[InternetGatewayId](#cfn-ec2-vpcgatewayattachment-internetgatewayid)" : {{String}}, "[VpcId](#cfn-ec2-vpcgatewayattachment-vpcid)" : {{String}}, "[VpnGatewayId](#cfn-ec2-vpcgatewayattachment-vpngatewayid)" : {{String}} } } ``` ### YAML ``` Type: AWS::EC2::VPCGatewayAttachment Properties: [InternetGatewayId](#cfn-ec2-vpcgatewayattachment-internetgatewayid): {{String}} [VpcId](#cfn-ec2-vpcgatewayattachment-vpcid): {{String}} [VpnGatewayId](#cfn-ec2-vpcgatewayattachment-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](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) `VpcId` The ID of the VPC. *Required*: Yes *Type*: String *Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-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](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) ## 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 [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html). ## 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 + [AttachVpnGateway](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AttachVpnGateway.html) in the *Amazon EC2 API Reference* + [Internet gateways](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html) in the *Amazon VPC User Guide*

AltStyle によって変換されたページ (->オリジナル) /