{{- range $ind, $cidr := .PrivateSubnetCIDRs}} NatGateway{{inc $ind}}Attachment: Metadata: 'aws:copilot:description': 'An Elastic IP for NAT Gateway {{inc $ind}}' Type: AWS::EC2::EIP Condition: CreateNATGateways DependsOn: InternetGatewayAttachment Properties: Domain: vpc NatGateway{{inc $ind}}: Metadata: 'aws:copilot:description': 'NAT Gateway {{inc $ind}} enabling workloads placed in private subnet {{inc $ind}} to reach the internet' Type: AWS::EC2::NatGateway Condition: CreateNATGateways Properties: AllocationId: !GetAtt NatGateway{{inc $ind}}Attachment.AllocationId SubnetId: !Ref PublicSubnet{{inc $ind}} Tags: - Key: Name Value: !Sub 'copilot-${AppName}-${EnvironmentName}-{{$ind}}' PrivateRouteTable{{inc $ind}}: Type: AWS::EC2::RouteTable Condition: CreateNATGateways Properties: VpcId: !Ref 'VPC' PrivateRoute{{inc $ind}}: Type: AWS::EC2::Route Condition: CreateNATGateways Properties: RouteTableId: !Ref PrivateRouteTable{{inc $ind}} DestinationCidrBlock: 0.0.0.0/0 NatGatewayId: !Ref NatGateway{{inc $ind}} PrivateRouteTable{{inc $ind}}Association: Type: AWS::EC2::SubnetRouteTableAssociation Condition: CreateNATGateways Properties: RouteTableId: !Ref PrivateRouteTable{{inc $ind}} SubnetId: !Ref PrivateSubnet{{inc $ind}} {{- end}}