Project: KICS (Provisioning / Security & Compliance)
File: 97e94d17-e2c7-4109-a53b-6536ac1bb64e.md

title: VPC Attached With Too Many Gateways hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 97e94d17-e2c7-4109-a53b-6536ac1bb64e Query name: VPC Attached With Too Many Gateways Platform: CloudFormation Severity: <span style="color:#edd57e">Low</span> Category: Availability URL: The number of gateways attached should not approach or go beyond the limit of 3, in a particular VPC<br> ```yaml title="Positive test num. 1 - yaml file" hl_lines="3" AWSTemplateFormatVersion: '2010-09-09' Resources: myVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsSupport: 'false' EnableDnsHostnames: 'false' InstanceTenancy: dedicated 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 ``` ```json title="Positive test num. 2 - json file" hl_lines="7" { "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "AttachVpnGateway4": { "Properties": { "VpcId": { "Ref": "myVPC" }, "VpnGatewayId": { "Ref": "myVPNGateway4" } }, "Type": "AWS::EC2::VPCGatewayAttachment" }, "myVPC": { "Type": "AWS::EC2::VPC", "Properties": { "EnableDnsHostnames": "false", "InstanceTenancy": "dedicated", "CidrBlock": "10.0.0.0/16", "EnableDnsSupport": "false" } }, "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" } } } } } ``` ```yaml title="Negative test num. 1 - yaml file" AWSTemplateFormatVersion: '2010-09-09' Resources: myVPC_2: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsSupport: 'false' EnableDnsHostnames: 'false' InstanceTenancy: dedicated AttachVpnGateway: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: Ref: myVPC_2 VpnGatewayId: Ref: myVPNGateway AttachVpnGateway2: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: Ref: myVPC_2 VpnGatewayId: Ref: myVPNGateway2 AttachVpnGateway3: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: Ref: myVPC_2 VpnGatewayId: Ref: myVPNGateway3 ``` ```json title="Negative test num. 2 - json file" { "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "myVPC_2": { "Type": "AWS::EC2::VPC", "Properties": { "CidrBlock": "10.0.0.0/16", "EnableDnsSupport": "false", "EnableDnsHostnames": "false", "InstanceTenancy": "dedicated" } }, "AttachVpnGateway": { "Type": "AWS::EC2::VPCGatewayAttachment", "Properties": { "VpcId": { "Ref": "myVPC_2" }, "VpnGatewayId": { "Ref": "myVPNGateway" } } }, "AttachVpnGateway2": { "Type": "AWS::EC2::VPCGatewayAttachment", "Properties": { "VpcId": { "Ref": "myVPC_2" }, "VpnGatewayId": { "Ref": "myVPNGateway2" } } }, "AttachVpnGateway3": { "Type": "AWS::EC2::VPCGatewayAttachment", "Properties": { "VpcId": { "Ref": "myVPC_2" }, "VpnGatewayId": { "Ref": "myVPNGateway3" } } } } } ```