{
    "AWSTemplateFormatVersion": "2010-09-09",

    "Parameters": {
        "KeyName": {
            "Description": "Key Pair name for Load Balancer",
            "Type": "String",
            "Default": "murano-lb-key"
        }
    },

    "Resources": {
        "$instanceName": {
            "Type": "AWS::EC2::Instance",
            "Properties": {
                "InstanceType": "$instanceType",
                "ImageId": "$imageName",
                "AvailabilityZone": "$availabilityZone",
                "UserData": "$userData",
                "NetworkInterfaces": [ { "Ref": "$port-{instanceName}" } ]
            }
        },
        "$port-{instanceName}": {
            "Type": "OS::Quantum::Port",
            "Properties": {
                "network_id": {
                    "Ref": "network"
                },
                "security_groups" : [ { "Ref" : "MuranoDefaultSecurityGroup"}],
                "fixed_ips": [
                    {
                        "subnet_id": {
                            "Ref": "subnet"
                        }
                    }
                ]
            }
        },
        "MuranoDefaultSecurityGroup": {
            "Type": "AWS::EC2::SecurityGroup",
            "Properties": {
                "SecurityGroupIngress": [
                    {
                        "ToPort": "3389",
                        "IpProtocol": "tcp",
                        "FromPort": "3389",
                        "CidrIp": "0.0.0.0/0"
                    },
                    {
                        "ToPort": "-1",
                        "IpProtocol": "icmp",
                        "FromPort": "-1",
                        "CidrIp": "0.0.0.0/0"
                    },
                    {
                        "FromPort": "5985",
                        "ToPort": "5986",
                        "IpProtocol": "tcp",
                        "CidrIp": "10.0.0.0/24"
                    }
                ],
                "GroupDescription": "Default security group for Windows Murano Environments"
            }
        },
        "network": {
            "Type": "OS::Quantum::Net",
            "Properties": {
                "name": "$network-{environmentId}"
            }
        },
        "subnet": {
            "Type": "OS::Quantum::Subnet",
            "Properties": {
                "network_id": {
                    "Ref": "network"
                },
                "ip_version": 4,
                "cidr": "10.0.0.0/24",
                "dns_nameservers": ["8.8.8.8"],
                "allocation_pools": [
                    {
                        "start": "10.0.0.20",
                        "end": "10.0.0.250"
                    }
                ]
            }
        },
        "router": {
            "Type": "OS::Quantum::Router"
        },
        "router_interface": {
            "Type": "OS::Quantum::RouterInterface",
            "Properties": {
                "router_id": {
                    "Ref": "router"
                },
                "subnet_id": {
                    "Ref": "subnet"
                }
            }
        },
        "router_gateway": {
            "Type": "OS::Quantum::RouterGateway",
            "Properties": {
                "router_id": {
                    "Ref": "router"
                },
                "network_id": "$externalNetworkId"
            }
        }
    },

    "Outputs": {
    }
}
