AWSTemplateFormatVersion: 2010-09-09 Description: Deploy a VPC Resources: #VPC1-1 VPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.10.10.0/23 EnableDnsHostnames: true Tags: - Key: Name Value: dev-vpc #VPC1-2 InternetGateway: Type: AWS::EC2::InternetGateway Properties: Tags: - Key: Name Value: igw #VPC1-3 AttachGateway: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: !Ref VPC InternetGatewayId: !Ref InternetGateway #Pub-subnet3-1 PublicSubnet1: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.10.0/26 AvailabilityZone: !Select - '0' - !GetAZs '' Tags: - Key: Name Value: Pub-Subnet-a #Pri-subnet3-1 PrivateSubnet1: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.11.0/26 AvailabilityZone: !Select - '0' - !GetAZs '' Tags: - Key: Name Value: Pri-Subnet-a #dbsubnert2-1 dbsubnert1: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.10.192/26 AvailabilityZone: !Select - '0' - !GetAZs '' Tags: - Key: Name Value: db-subnet-a #Pub-subnet3-2 PublicSubnet2: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.10.64/26 AvailabilityZone: !Select - '1' - !GetAZs '' Tags: - Key: Name Value: Pub-Subnet-b #Pri-subnet3-2 PrivateSubnet2: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.11.64/26 AvailabilityZone: !Select - '1' - !GetAZs '' Tags: - Key: Name Value: Pri-Subnet-b #Pub-subnet3-3 PublicSubnet3: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.10.128/26 AvailabilityZone: !Select - '2' - !GetAZs '' Tags: - Key: Name Value: Pub-Subnet-c #Pri-subnet3-3 PrivateSubnet3: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.11.128/26 AvailabilityZone: !Select - '2' - !GetAZs '' Tags: - Key: Name Value: Pri-Subnet-c #dbsubnert2-2 dbsubnert3: Type: AWS::EC2::Subnet Properties: VpcId: !Ref VPC CidrBlock: 10.10.11.192/26 AvailabilityZone: !Select - '2' - !GetAZs '' Tags: - Key: Name Value: db-subnet-c #Pub-subnet3-4 PublicRouteTable: Type: AWS::EC2::RouteTable Properties: VpcId: !Ref VPC Tags: - Key: Name Value: Pub-rt #Pub-subnet3-5 PublicRoute: Type: AWS::EC2::Route Properties: RouteTableId: !Ref PublicRouteTable DestinationCidrBlock: 0.0.0.0/0 GatewayId: !Ref InternetGateway #Pub-subnet3-6 PublicSubnetRouteTableAssociation1: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref PublicSubnet1 RouteTableId: !Ref PublicRouteTable #Pub-subnet3-7 PublicSubnetRouteTableAssociation2: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref PublicSubnet2 RouteTableId: !Ref PublicRouteTable #Pub-subnet3-8 PublicSubnetRouteTableAssociation3: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref PublicSubnet3 RouteTableId: !Ref PublicRouteTable #Pri-subnet3-4 PrivateRouteTable: Type: AWS::EC2::RouteTable Properties: VpcId: !Ref VPC Tags: - Key: Name Value: Pri-rt #Pri-subnet3-5 PrivateSubnetRouteTableAssociation1: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref PrivateSubnet1 RouteTableId: !Ref PrivateRouteTable #Pri-subnet3-6 PrivateSubnetRouteTableAssociation2: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref PrivateSubnet2 RouteTableId: !Ref PrivateRouteTable #Pri-subnet3-7 PrivateSubnetRouteTableAssociation3: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref PrivateSubnet3 RouteTableId: !Ref PrivateRouteTable #dbsubnert2-3 dbroutettable: Type: AWS::EC2::RouteTable Properties: VpcId: !Ref VPC Tags: - Key: Name Value: db-rt #dbsubnert2-4 dbsubnertRouteTableAssociation1: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref dbsubnert1 RouteTableId: !Ref dbroutettable #dbsubnert2-5 dbsubnertRouteTableAssociation3: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref dbsubnert3 RouteTableId: !Ref dbroutettable Outputs: VPC: Description: VPC Value: !Ref VPC AZ1: Description: Availability Zone 1 Value: !GetAtt - PublicSubnet1 - AvailabilityZone AZ2: Description: Availability Zone 2 Value: !GetAtt - PublicSubnet2 - AvailabilityZone AZ3: Description: Availability Zone 2 Value: !GetAtt - PublicSubnet3 - AvailabilityZone