VPC gateway attachment limit exceeded

Follow the attachment limits for each gateway type.

Description

A VPC can attach one internet gateway and one virtual private gateway at a time. Limits apply separately to each gateway type.

Potential impact

Attaching a second virtual private gateway to the same VPC fails.

Remediation

Keep the required attachment and remove duplicates. Before replacing a live attachment, check which routes and VPN connections depend on it.

Examples

The first excerpt tries to attach four virtual private gateways to myVPC. The second attaches only myVPNGateway. Define the VPC and gateway separately.

Before

yaml
Resources:
  AttachVpnGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: myVPC
      VpnGatewayId:
        Ref: myVPNGateway

  AttachVpnGateway2:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: myVPC
      VpnGatewayId:
        Ref: myVPNGateway2

  AttachVpnGateway3:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: myVPC
      VpnGatewayId:
        Ref: myVPNGateway3

  AttachVpnGateway4:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: myVPC
      VpnGatewayId:
        Ref: myVPNGateway4

After

yaml
Resources:
  AttachVpnGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: myVPC
      VpnGatewayId:
        Ref: myVPNGateway

References