{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Resources": {
        "InternetGateway": {
            "Type": "AWS::EC2::InternetGateway",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/InternetGateway"
                        }
                    }
                ]
            }
        },
        "NATGateway": {
            "Type": "AWS::EC2::NatGateway",
            "Properties": {
                "AllocationId": {
                    "Fn::GetAtt": ["NATIP", "AllocationId"]
                },
                "SubnetId": {
                    "Ref": "SubnetPublicUSWEST2A"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/NATGateway"
                        }
                    }
                ]
            }
        },
        "NATIP": {
            "Type": "AWS::EC2::EIP",
            "Properties": {
                "Domain": "vpc",
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/NATIP"
                        }
                    }
                ]
            }
        },
        "NATPrivateSubnetRouteUSWEST2A": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "NatGatewayId": {
                    "Ref": "NATGateway"
                },
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2A"
                }
            }
        },
        "NATPrivateSubnetRouteUSWEST2B": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "NatGatewayId": {
                    "Ref": "NATGateway"
                },
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2B"
                }
            }
        },
        "NATPrivateSubnetRouteUSWEST2C": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "NatGatewayId": {
                    "Ref": "NATGateway"
                },
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2C"
                }
            }
        },
        "NATPrivateSubnetRouteUSWEST2D": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "NatGatewayId": {
                    "Ref": "NATGateway"
                },
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2D"
                }
            }
        },
        "PrivateRouteTableUSWEST2A": {
            "Type": "AWS::EC2::RouteTable",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/PrivateRouteTableUSWEST2A"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "PrivateRouteTableUSWEST2B": {
            "Type": "AWS::EC2::RouteTable",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/PrivateRouteTableUSWEST2B"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "PrivateRouteTableUSWEST2C": {
            "Type": "AWS::EC2::RouteTable",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/PrivateRouteTableUSWEST2C"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "PrivateRouteTableUSWEST2D": {
            "Type": "AWS::EC2::RouteTable",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/PrivateRouteTableUSWEST2D"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "PublicRouteTable": {
            "Type": "AWS::EC2::RouteTable",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/PublicRouteTable"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "PublicSubnetRoute": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "GatewayId": {
                    "Ref": "InternetGateway"
                },
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                }
            },
            "DependsOn": [
                "VPCGatewayAttachment"
            ]
        },
        "RouteTableAssociationPrivateUSWEST2A": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2A"
                },
                "SubnetId": {
                    "Ref": "SubnetPrivateUSWEST2A"
                }
            }
        },
        "RouteTableAssociationPrivateUSWEST2B": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2B"
                },
                "SubnetId": {
                    "Ref": "SubnetPrivateUSWEST2B"
                }
            }
        },
        "RouteTableAssociationPrivateUSWEST2C": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2C"
                },
                "SubnetId": {
                    "Ref": "SubnetPrivateUSWEST2C"
                }
            }
        },
        "RouteTableAssociationPrivateUSWEST2D": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTableUSWEST2D"
                },
                "SubnetId": {
                    "Ref": "SubnetPrivateUSWEST2D"
                }
            }
        },
        "RouteTableAssociationPublicUSWEST2A": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "SubnetPublicUSWEST2A"
                }
            }
        },
        "RouteTableAssociationPublicUSWEST2B": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "SubnetPublicUSWEST2B"
                }
            }
        },
        "RouteTableAssociationPublicUSWEST2C": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "SubnetPublicUSWEST2C"
                }
            }
        },
        "RouteTableAssociationPublicUSWEST2D": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "SubnetPublicUSWEST2D"
                }
            }
        },
        "SubnetPrivateUSWEST2A": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2a",
                "CidrBlock": "192.168.128.0/19",
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/internal-elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPrivateUSWEST2A"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPrivateUSWEST2B": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2b",
                "CidrBlock": "192.168.160.0/19",
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/internal-elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPrivateUSWEST2B"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPrivateUSWEST2C": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2c",
                "CidrBlock": "192.168.192.0/19",
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/internal-elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPrivateUSWEST2C"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPrivateUSWEST2D": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2d",
                "CidrBlock": "192.168.224.0/19",
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/internal-elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPrivateUSWEST2D"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPublicUSWEST2A": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2a",
                "CidrBlock": "192.168.0.0/19",
                "MapPublicIpOnLaunch": true,
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPublicUSWEST2A"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPublicUSWEST2B": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2b",
                "CidrBlock": "192.168.32.0/19",
                "MapPublicIpOnLaunch": true,
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPublicUSWEST2B"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPublicUSWEST2C": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2c",
                "CidrBlock": "192.168.64.0/19",
                "MapPublicIpOnLaunch": true,
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPublicUSWEST2C"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "SubnetPublicUSWEST2D": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": "us-west-2d",
                "CidrBlock": "192.168.96.0/19",
                "MapPublicIpOnLaunch": true,
                "Tags": [
                    {
                        "Key": "kubernetes.io/role/elb",
                        "Value": "1"
                    },
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/SubnetPublicUSWEST2D"
                        }
                    }
                ],
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        },
        "VPC": {
            "Type": "AWS::EC2::VPC",
            "Properties": {
                "CidrBlock": "192.168.0.0/16",
                "EnableDnsHostnames": true,
                "EnableDnsSupport": true,
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Sub": "${AWS::StackName}/VPC"
                        }
                    }
                ]
            }
        },
        "VPCGatewayAttachment": {
            "Type": "AWS::EC2::VPCGatewayAttachment",
            "Properties": {
                "InternetGatewayId": {
                    "Ref": "InternetGateway"
                },
                "VpcId": {
                    "Ref": "VPC"
                }
            }
        }
    }
}
