ALIYUN::VPC::EIPAssociation

ALIYUN::VPC::EIPAssociation用于为云产品实例绑定弹性公网IP(EIP)。

语法

{
  "Type": "ALIYUN::VPC::EIPAssociation",
  "Properties": {
    "AllocationId": String,
    "InstanceId": String,
    "PrivateIpAddress": String,
    "Mode": String
  }
}         

属性

属性名称

类型

必须

允许更新

描述

约束

AllocationId

String

弹性公网IPID。

InstanceId

String

云产品实例的ID。

支持以下云产品实例类型:

  • VPC类型的ECS实例。

  • VPC类型的SLB实例。

  • NAT网关。

  • 高可用虚拟IP(HaVip)。

  • 弹性网卡。

PrivateIpAddress

String

交换机网段内的一个私网IP地址。

如果不指定该参数,系统将根据VPC ID和交换机ID自动分配一个私网IP地址。

Mode

String

绑定模式。

取值:

  • NAT(默认值):NAT模式(普通模式)。

  • MULTI_BINDED:多EIP网卡可见模式。

  • BINDED:EIP网卡可见模式。

返回值

Fn::GetAtt

  • EipAddress:弹性公网IP的地址。

  • AllocationId:弹性公网IPID。

示例

场景 1 :创建单个ECS,并绑定EIP

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: Create a VPC type ECS and bind EIP (existing VPC).
  zh-cn: 创建VPC类型ECS,并绑定EIP(已有VPC)。
Parameters:
  VPC:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Description:
      en: Please search the ID starting with (vpc-xxx) from console-Virtual Private Cloud.
      zh-cn: 现有专有网络的实例ID,在专有网络控制台选择专有网络进行查询。
    Label:
      en: VPC ID
      zh-cn: 专有网络VPC实例ID
  VSwitch:
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VPC}
    Type: String
    Description:
      en: Existing VSwitch ID, query under console-VPC-VSwitch, <font color='red'>VSwitch must be under VPC. ECS will be created under this VSwitch.</font>
      zh-cn: 现有交换机ID,在专有网络控制台选择交换机进行查询,<font color='red'>交换机必须在VPC下。ECS将创建在此交换机下。</font>
    Label:
      en: VSwitch ID
      zh-cn: 交换机实例ID
  SecurityGroup:
    Type: String
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    Description:
      en: Please search the business security group ID starting with (sg-xxx) from console-ECS-Network & Security.
      zh-cn: 现有业务安全组的实例ID,在ECS控制台选择安全组进行查询。<br><font color='red'>安全组必须归属在VPC下。</font>
    Label:
      en: Business Security Group ID
      zh-cn: 业务安全组ID
    AssociationPropertyMetadata:
      VpcId: ${VPC}
  ECSInstanceType:
    AssociationPropertyMetadata:
      InstanceChargeType: ${ECSInstanceType}
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    Type: String
    Description:
      en: <font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
      zh-cn: <font color='blue'><b>1、选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备。</b></font><br><font color='blue'><b>2、取值:</font><br></b></font>[ecs.c5.large:<font color='green'>2vCPU 4 GiB,内网带宽1Gbps、内网收发包30万PPS。</font>]<br></b>[ecs.c5.xlarge:<font color='green'>4vCPU 8GiB,内网带宽1.5Gbps、内网收发包50万PPS。</font>]<br></b>[ecs.c5.2xlarge: <font color='green'>8vCPU 16 GiB,内网带宽2.5 Gbps、内网收发包80万PPS。</font>]
    Label:
      en: Instance Type
      zh-cn: 实例规格
  ECSDiskCategory:
    Type: String
    Description:
      en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency: <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud: <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD Cloud Disk</font>]'
      zh-cn: '<font color=''blue''><b>取值:</b></font><br>[cloud_efficiency: <font color=''green''>高效云盘</font>]<br>[cloud_ssd: <font color=''green''>SSD云盘</font>]<br>[cloud_essd: <font color=''green''>ESSD云盘</font>]<br>[cloud: <font color=''green''>普通云盘</font>]<br>[ephemeral_ssd: <font color=''green''>本地SSD盘</font>]'
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      InstanceType: ${ECSInstanceType}
    Label:
      en: System Disk Type
      zh-cn: 系统盘类型
  InstanceChargeType:
    Type: String
    Label:
      en: Instance Charge Type
      zh-cn: 实例的付费方式
    Description:
      en: '<font color=''blue''><b>Optional values:</b></font><br>[PostPaid: <font color=''green''>Pay as you go.</font>]<br> [PrePaid: <font color=''green''>Prepaid, monthly subscription.</font>]'
      zh-cn: '<font color=''blue''><b>取值:</b></font><br>[PostPaid: <font color=''green''>按量付费。</font>]<br>[PrePaid: <font color=''green''>预付费,包年包月。</font>]'
    AllowedValues:
      - PostPaid
      - PrePaid
    Default: PostPaid
  KeyPairName:
    Type: String
    AssociationProperty: ALIYUN::ECS::KeyPair::KeyPairName
    Label:
      en: Key Pair Name
      zh-cn: 密钥对名称
    Description:
      en: If it is a Windows ECS instance, ignore this parameter. The default is blank.<br>If you have filled in <font color='green'>key pair name</font>, <font color='green'>instance password< The content of /font> will still be set in the instance, but the password login method in the Linux system will be forbidden.<br><font color='red'>Please enter the name of the existing key pair. If you use the instance password Login, the key pair name does not need to be filled in.</font>
      zh-cn: 如果是Windows ECS实例,则忽略该参数。默认为空。<br>如果已填写<font color='green'>密钥对名称</font>,<font color='green'>实例密码</font>的内容仍会被设置到实例中,但是Linux系统中的密码登录方式会被禁止。<br><font color='red'>请输入已有密钥对的名称。如使用实例密码登录,密钥对名称不需要填写。</font>
    Default: Null
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - VPC
          - VSwitch
          - SecurityGroup
        Label:
          default: 'VPC '
      - Parameters:
          - ECSInstanceType
          - ECSDiskCategory
          - InstanceChargeType
          - KeyPairName
        Label:
          default: ECS
    TemplateTags:
      - Specify the image Id and snapshot to create ECS instance.
Resources:
  ECSInstanceGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      IoOptimized: optimized
      InstanceChargeType:
        Ref: InstanceChargeType
      SystemDisk_Category:
        Ref: ECSDiskCategory
      SecurityGroupId:
        Ref: SecurityGroup
      VSwitchId:
        Ref: VSwitch
      MaxAmount: 1
      SystemDisk_Size: 40
      VpcId:
        Ref: VPC
      ImageId: ubuntu_14
      InstanceType:
        Ref: ECSInstanceType
      AllocatePublicIP: 'false'
      Password: Admin@123!
      KeyPairName:
        Ref: KeyPairName
  ElasticIp:
    Type: ALIYUN::VPC::EIP
    Properties:
      Bandwidth: 5
      InternetChargeType: PayByTraffic
  ElasticIpAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Fn::Select:
          - 0
          - Fn::GetAtt:
              - ECSInstanceGroup
              - InstanceIds
      AllocationId:
        Ref: ElasticIp
Outputs:
  VpcId:
    Description: VPC Id
    Value:
      Ref: VPC
  SecurityGroupId:
    Description: Security Group Id
    Value:
      Ref: SecurityGroup
  VSwitchId:
    Description: VSwitch Id
    Value:
      Ref: VSwitch
  EipAddress:
    Description: IP address of created EIP.
    Value:
      Fn::GetAtt:
        - ElasticIp
        - EipAddress
                    
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "en": "Create a VPC type ECS and bind EIP (existing VPC).",
    "zh-cn": "创建VPC类型ECS,并绑定EIP(已有VPC)。"
  },
  "Parameters": {
    "VPC": {
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
      "Type": "String",
      "Description": {
        "en": "Please search the ID starting with (vpc-xxx) from console-Virtual Private Cloud.",
        "zh-cn": "现有专有网络的实例ID,在专有网络控制台选择专有网络进行查询。"
      },
      "Label": {
        "en": "VPC ID",
        "zh-cn": "专有网络VPC实例ID"
      }
    },
    "VSwitch": {
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VPC}"
      },
      "Type": "String",
      "Description": {
        "en": "Existing VSwitch ID, query under console-VPC-VSwitch, <font color='red'>VSwitch must be under VPC. ECS will be created under this VSwitch.</font>",
        "zh-cn": "现有交换机ID,在专有网络控制台选择交换机进行查询,<font color='red'>交换机必须在VPC下。ECS将创建在此交换机下。</font>"
      },
      "Label": {
        "en": "VSwitch ID",
        "zh-cn": "交换机实例ID"
      }
    },
    "SecurityGroup": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
      "Description": {
        "en": "Please search the business security group ID starting with (sg-xxx) from console-ECS-Network & Security.",
        "zh-cn": "现有业务安全组的实例ID,在ECS控制台选择安全组进行查询。<br><font color='red'>安全组必须归属在VPC下。</font>"
      },
      "Label": {
        "en": "Business Security Group ID",
        "zh-cn": "业务安全组ID"
      },
      "AssociationPropertyMetadata": {
        "VpcId": "${VPC}"
      }
    },
    "ECSInstanceType": {
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "${ECSInstanceType}"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "Type": "String",
      "Description": {
        "en": "<font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]",
        "zh-cn": "<font color='blue'><b>1、选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备。</b></font><br><font color='blue'><b>2、取值:</font><br></b></font>[ecs.c5.large:<font color='green'>2vCPU 4 GiB,内网带宽1Gbps、内网收发包30万PPS。</font>]<br></b>[ecs.c5.xlarge:<font color='green'>4vCPU 8GiB,内网带宽1.5Gbps、内网收发包50万PPS。</font>]<br></b>[ecs.c5.2xlarge: <font color='green'>8vCPU 16 GiB,内网带宽2.5 Gbps、内网收发包80万PPS。</font>]"
      },
      "Label": {
        "en": "Instance Type",
        "zh-cn": "实例规格"
      }
    },
    "ECSDiskCategory": {
      "Type": "String",
      "Description": {
        "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]",
        "zh-cn": "<font color='blue'><b>取值:</b></font><br>[cloud_efficiency: <font color='green'>高效云盘</font>]<br>[cloud_ssd: <font color='green'>SSD云盘</font>]<br>[cloud_essd: <font color='green'>ESSD云盘</font>]<br>[cloud: <font color='green'>普通云盘</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盘</font>]"
      },
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${ECSInstanceType}"
      },
      "Label": {
        "en": "System Disk Type",
        "zh-cn": "系统盘类型"
      }
    },
    "InstanceChargeType": {
      "Type": "String",
      "Label": {
        "en": "Instance Charge Type",
        "zh-cn": "实例的付费方式"
      },
      "Description": {
        "en": "<font color='blue'><b>Optional values:</b></font><br>[PostPaid: <font color='green'>Pay as you go.</font>]<br> [PrePaid: <font color='green'>Prepaid, monthly subscription.</font>]",
        "zh-cn": "<font color='blue'><b>取值:</b></font><br>[PostPaid: <font color='green'>按量付费。</font>]<br>[PrePaid: <font color='green'>预付费,包年包月。</font>]"
      },
      "AllowedValues": [
        "PostPaid",
        "PrePaid"
      ],
      "Default": "PostPaid"
    },
    "KeyPairName": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::KeyPair::KeyPairName",
      "Label": {
        "en": "Key Pair Name",
        "zh-cn": "密钥对名称"
      },
      "Description": {
        "en": "If it is a Windows ECS instance, ignore this parameter. The default is blank.<br>If you have filled in <font color='green'>key pair name</font>, <font color='green'>instance password< The content of /font> will still be set in the instance, but the password login method in the Linux system will be forbidden.<br><font color='red'>Please enter the name of the existing key pair. If you use the instance password Login, the key pair name does not need to be filled in.</font>",
        "zh-cn": "如果是Windows ECS实例,则忽略该参数。默认为空。<br>如果已填写<font color='green'>密钥对名称</font>,<font color='green'>实例密码</font>的内容仍会被设置到实例中,但是Linux系统中的密码登录方式会被禁止。<br><font color='red'>请输入已有密钥对的名称。如使用实例密码登录,密钥对名称不需要填写。</font>"
      },
      "Default": null
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VPC",
            "VSwitch",
            "SecurityGroup"
          ],
          "Label": {
            "default": "VPC "
          }
        },
        {
          "Parameters": [
            "ECSInstanceType",
            "ECSDiskCategory",
            "InstanceChargeType",
            "KeyPairName"
          ],
          "Label": {
            "default": "ECS"
          }
        }
      ],
      "TemplateTags": [
        "Specify the image Id and snapshot to create ECS instance."
      ]
    }
  },
  "Resources": {
    "ECSInstanceGroup": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "IoOptimized": "optimized",
        "InstanceChargeType": {
          "Ref": "InstanceChargeType"
        },
        "SystemDisk_Category": {
          "Ref": "ECSDiskCategory"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "MaxAmount": 1,
        "SystemDisk_Size": 40,
        "VpcId": {
          "Ref": "VPC"
        },
        "ImageId": "ubuntu_14",
        "InstanceType": {
          "Ref": "ECSInstanceType"
        },
        "AllocatePublicIP": "false",
        "Password": "Admin@123!",
        "KeyPairName": {
          "Ref": "KeyPairName"
        }
      }
    },
    "ElasticIp": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "Bandwidth": 5,
        "InternetChargeType": "PayByTraffic"
      }
    },
    "ElasticIpAssociation": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Fn::Select": [
            0,
            {
              "Fn::GetAtt": [
                "ECSInstanceGroup",
                "InstanceIds"
              ]
            }
          ]
        },
        "AllocationId": {
          "Ref": "ElasticIp"
        }
      }
    }
  },
  "Outputs": {
    "VpcId": {
      "Description": "VPC Id",
      "Value": {
        "Ref": "VPC"
      }
    },
    "SecurityGroupId": {
      "Description": "Security Group Id",
      "Value": {
        "Ref": "SecurityGroup"
      }
    },
    "VSwitchId": {
      "Description": "VSwitch Id",
      "Value": {
        "Ref": "VSwitch"
      }
    },
    "EipAddress": {
      "Description": "IP address of created EIP.",
      "Value": {
        "Fn::GetAtt": [
          "ElasticIp",
          "EipAddress"
        ]
      }
    }
  }
}

场景 2 :创建多个ECS,并绑定EIP

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建指定数量的VPC内ECS实例,配备EIP,按配置计费与带宽,于指定交换机与安全组下。
  en: Provision a specified number of ECS instances within a designated VPC, equipped with Elastic IP Addresses (EIPs), billed by configuration and bandwidth usage, placed under the specified virtual switch (VSwitch) and security group.
Parameters:
  VPC:
    Type: String
    Label:
      en: VPC ID
      zh-cn: 专有网络VPC实例ID
    Description:
      en: Please search the ID starting with (vpc-xxx)from console-Virtual Private Cloud
      zh-cn: 现有虚拟专有网络的实例ID,控制台-VPC-专有网络下查询
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
  VSwitch:
    Type: String
    Label:
      en: VSwitch ID
      zh-cn: 交换机实例ID
    Description:
      en: Existing VSwitch ID, query under console-VPC-VSwitch, <font color='red'>VSwitch must be under VPC. ECS will be created under this VSwitch</font>
      zh-cn: 现有交换机ID,控制台-VPC-交换机下查询,<font color='red'>交换机必须在VPC下。ECS将创建在此交换机下</font>
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VPC}
      ZoneId: ${ECSZoneId}
  SecurityGroup:
    Type: String
    Label:
      en: Business Security Group ID
      zh-cn: 业务安全组ID
    Description:
      en: Please search the business security group ID starting with(sg-xxx)from console-ECS-Network & Security
      zh-cn: 现有业务安全组的实例ID,控制台-ECS-网络与安全-安全组下查询。<br><font color='red'>安全组必须归属在VPC下。</font>
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    AssociationPropertyMetadata:
      VpcId: ${VPC}
  EIPBandwidth:
    Type: Number
    Label:
      en: EIP Bandwidth
      zh-cn: 弹性公网带宽
    Description:
      en: 'EIP Bandwidth, Value range: [1,200], unit: Mbps.'
      zh-cn: 弹性公网地址带宽。取值范围:1~200, 单位:Mbps。
    Default: 1
    MinValue: 1
    MaxValue: 200
  EIPInternetChargeType:
    Type: String
    Label:
      en: EIP Charge Type
      zh-cn: 弹性公网地址的收费类型
    AssociationPropertyMetadata:
      LocaleKey: InternetChargeType
    Default: PayByTraffic
    AllowedValues:
      - PayByBandwidth
      - PayByTraffic
  Count:
    Type: Number
    Label:
      en: Count
      zh-cn: 数量
    Description:
      en: 'The number of ecs and eip to be created, value range: [1,140]'
      zh-cn: 需要创建的ecs和eip的数量,取值范围:[1,140]
    Default: 2
    MinValue: 1
    MaxValue: 140
  ECSZoneId:
    Type: String
    Label:
      en: VSwitch Availability Zone
      zh-cn: 交换机可用区
    Description:
      en: 'Availability zone ID.<br><b>Note: <font color=''blue''>Before selecting, please confirm whether the availability zone supports the specification of creating ECS resources. It is recommended to be different from other switch availability zones</font></b ><br><font color=''red''>The switch availability zone and the selected switch instance ID must be in the same availability zone.</font>'
      zh-cn: 可用区ID。<br><b>注: <font color='blue'>选择前请确认该可用区是否支持创建ECS资源的规格,建议与其他交换机可用区不同</font></b><br><font color='red'>交换机可用区和已选择的交换机实例ID必须在同一个可用区。</font>
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
  ECSImageId:
    Type: String
    Label:
      en: Image
      zh-cn: 镜像
    Description:
      en: Image ID,Please use Centos7, see detail:<b><a href='https://www.alibabacloud.com/help/en/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>
      zh-cn: 镜像ID, 请使用Centos7, 详见:<b><a href='https://help.aliyun.com/document_detail/112977.html' target='_blank'><font color='blue'>查找镜像</font></a></b>
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    AssociationPropertyMetadata:
      InstanceType: ${ECSInstanceType}
      SupportedImageOwnerAlias:
        - system
        - self
        - others
    Default: centos_7_04_64_20G_alibase_201701015.vhd
  ECSInstanceType:
    Type: String
    Label:
      en: Instance Type
      zh-cn: 实例规格
    Description:
      en: <font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
      zh-cn: <font color='blue'><b>1.选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备</b></font><br><font color='blue'><b>2.可选机型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 内网带宽1Gbps 内网收发包30万PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 内网带宽1.5Gbps 内网收发包50万PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 内网带宽2.5Gbps 内网收发包80万PPS</font>]
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ECSZoneId
  ECSDiskCategory:
    Type: String
    Label:
      en: System Disk Type
      zh-cn: 系统盘类型
    Description:
      en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency: <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud: <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD Cloud Disk</font>]'
      zh-cn: '<font color=''blue''><b>可选值:</b></font><br>[cloud_efficiency: <font color=''green''>高效云盘</font>]<br>[cloud_ssd: <font color=''green''>SSD云盘</font>]<br>[cloud_essd: <font color=''green''>ESSD云盘</font>]<br>[cloud: <font color=''green''>普通云盘</font>]<br>[ephemeral_ssd: <font color=''green''>本地SSD盘</font>]'
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      LocaleKey: DiskCategory
      InstanceType: ${ECSInstanceType}
  ECSSysDiskSize:
    Type: Number
    Label:
      en: System Disk Space
      zh-cn: 系统盘空间
    Description:
      en: 'System disk size, range of values: 40-500, units: GB.'
      zh-cn: 系统盘大小, 取值范围:[40, 500], 单位:GB。
    Default: 40
    MinValue: 40
    MaxValue: 500
  ECSPassword:
    Type: String
    NoEcho: true
    Label:
      en: Instance Password
      zh-cn: 实例密码
    Description:
      en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
      zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
    ConstraintDescription:
      en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
      zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
    Default: Null
    AssociationProperty: ALIYUN::ECS::Instance::Password
  KeyPairName:
    Type: String
    Label:
      en: Key Pair Name
      zh-cn: 密钥对名称
    Description:
      en: If it is a Windows ECS instance, ignore this parameter. The default is blank.<br>If you have filled in <font color='green'>key pair name</font>, <font color='green'>instance password< The content of /font> will still be set in the instance, but the password login method in the Linux system will be forbidden.<br><font color='red'>Please enter the name of the existing key pair. If you use the instance password Login, the key pair name does not need to be filled in</font>
      zh-cn: 如果是Windows ECS实例,则忽略该参数。默认为空。<br>如果已填写<font color='green'>密钥对名称</font>,<font color='green'>实例密码</font>的内容仍会被设置到实例中,但是Linux系统中的密码登录方式会被禁止。<br><font color='red'>请输入已有密钥对的名称。如使用实例密码登录,密钥对名称不需要填写</font>
    AssociationProperty: ALIYUN::ECS::KeyPair::KeyPairName
    Default: Null
  PayType:
    Type: String
    Label:
      en: ECS Instance Charge Type
      zh-cn: ECS付费类型
    AssociationProperty: ChargeType
    AssociationPropertyMetadata:
      LocaleKey: InstanceChargeType
    Default: PostPaid
    AllowedValues:
      - PostPaid
      - PrePaid
  PayPeriodUnit:
    Type: String
    Label:
      en: Pay Period Unit
      zh-cn: 购买资源时长周期
    AssociationProperty: PayPeriodUnit
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${PayType}
              - PostPaid
    Default: Month
    AllowedValues:
      - Month
      - Year
  PayPeriod:
    Type: Number
    Label:
      en: Period
      zh-cn: 购买资源时长
    AssociationProperty: PayPeriod
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${PayType}
              - PostPaid
    Default: 1
    AllowedValues:
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 7
      - 8
      - 9
Resources:
  ECSInstanceGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      ZoneId:
        Ref: ECSZoneId
      VpcId:
        Ref: VPC
      VSwitchId:
        Ref: VSwitch
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId:
        Ref: ECSImageId
      AllocatePublicIP: 'false'
      InstanceChargeType:
        Ref: PayType
      Period:
        Ref: PayPeriod
      PeriodUnit:
        Ref: PayPeriodUnit
      InstanceType:
        Ref: ECSInstanceType
      IoOptimized: optimized
      KeyPairName:
        Ref: KeyPairName
      MaxAmount:
        Ref: Count
      Password:
        Ref: ECSPassword
      SystemDiskCategory:
        Ref: ECSDiskCategory
      SystemDiskSize:
        Ref: ECSSysDiskSize
  ElasticIp:
    Type: ALIYUN::VPC::EIP
    Properties:
      Bandwidth:
        Ref: EIPBandwidth
      InternetChargeType:
        Ref: EIPInternetChargeType
    Count:
      Ref: Count
  ElasticIpAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Fn::Select:
          - Ref: ALIYUN::Index
          - Fn::GetAtt:
              - ECSInstanceGroup
              - InstanceIds
      AllocationId:
        Fn::Select:
          - Ref: ALIYUN::Index
          - Ref: ElasticIp
    Count:
      Ref: Count
Outputs:
  EipAddress:
    Description: IP address of created EIP.
    Value:
      Fn::GetAtt:
        - ElasticIp
        - EipAddress
  SecurityGroupId:
    Description: generated security group id for security group.
    Value:
      Ref: SecurityGroup
  VSwitchId:
    Description: generated security vswitch id for VPC.
    Value:
      Ref: VSwitch
  VpcId:
    Description: generated security vpc id for VPC.
    Value:
      Ref: VPC
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - VPC
          - ECSZoneId
          - VSwitch
          - SecurityGroup
        Label:
          default: 'VPC '
      - Parameters:
          - EIPBandwidth
          - EIPInternetChargeType
        Label:
          default: EIP
      - Parameters:
          - PayType
          - PayPeriodUnit
          - PayPeriod
        Label:
          default:
            en: ECS PayType Configuration
            zh-cn: ECS付费类型配置
      - Parameters:
          - ECSInstanceType
          - ECSImageId
          - ECSDiskCategory
          - ECSSysDiskSize
          - Count
          - ECSPassword
          - KeyPairName
        Label:
          default: ECS
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建指定数量的VPC内ECS实例,配备EIP,按配置计费与带宽,于指定交换机与安全组下。",
    "en": "Provision a specified number of ECS instances within a designated VPC, equipped with Elastic IP Addresses (EIPs), billed by configuration and bandwidth usage, placed under the specified virtual switch (VSwitch) and security group."
  },
  "Parameters": {
    "VPC": {
      "Type": "String",
      "Label": {
        "en": "VPC ID",
        "zh-cn": "专有网络VPC实例ID"
      },
      "Description": {
        "en": "Please search the ID starting with (vpc-xxx)from console-Virtual Private Cloud",
        "zh-cn": "现有虚拟专有网络的实例ID,控制台-VPC-专有网络下查询"
      },
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
    },
    "VSwitch": {
      "Type": "String",
      "Label": {
        "en": "VSwitch ID",
        "zh-cn": "交换机实例ID"
      },
      "Description": {
        "en": "Existing VSwitch ID, query under console-VPC-VSwitch, <font color='red'>VSwitch must be under VPC. ECS will be created under this VSwitch</font>",
        "zh-cn": "现有交换机ID,控制台-VPC-交换机下查询,<font color='red'>交换机必须在VPC下。ECS将创建在此交换机下</font>"
      },
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VPC}",
        "ZoneId": "${ECSZoneId}"
      }
    },
    "SecurityGroup": {
      "Type": "String",
      "Label": {
        "en": "Business Security Group ID",
        "zh-cn": "业务安全组ID"
      },
      "Description": {
        "en": "Please search the business security group ID starting with(sg-xxx)from console-ECS-Network & Security",
        "zh-cn": "现有业务安全组的实例ID,控制台-ECS-网络与安全-安全组下查询。<br><font color='red'>安全组必须归属在VPC下。</font>"
      },
      "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VPC}"
      }
    },
    "EIPBandwidth": {
      "Type": "Number",
      "Label": {
        "en": "EIP Bandwidth",
        "zh-cn": "弹性公网带宽"
      },
      "Description": {
        "en": "EIP Bandwidth, Value range: [1,200], unit: Mbps.",
        "zh-cn": "弹性公网地址带宽。取值范围:1~200, 单位:Mbps。"
      },
      "Default": 1,
      "MinValue": 1,
      "MaxValue": 200
    },
    "EIPInternetChargeType": {
      "Type": "String",
      "Label": {
        "en": "EIP Charge Type",
        "zh-cn": "弹性公网地址的收费类型"
      },
      "AssociationPropertyMetadata": {
        "LocaleKey": "InternetChargeType"
      },
      "Default": "PayByTraffic",
      "AllowedValues": [
        "PayByBandwidth",
        "PayByTraffic"
      ]
    },
    "Count": {
      "Type": "Number",
      "Label": {
        "en": "Count",
        "zh-cn": "数量"
      },
      "Description": {
        "en": "The number of ecs and eip to be created, value range: [1,140]",
        "zh-cn": "需要创建的ecs和eip的数量,取值范围:[1,140]"
      },
      "Default": 2,
      "MinValue": 1,
      "MaxValue": 140
    },
    "ECSZoneId": {
      "Type": "String",
      "Label": {
        "en": "VSwitch Availability Zone",
        "zh-cn": "交换机可用区"
      },
      "Description": {
        "en": "Availability zone ID.<br><b>Note: <font color='blue'>Before selecting, please confirm whether the availability zone supports the specification of creating ECS resources. It is recommended to be different from other switch availability zones</font></b ><br><font color='red'>The switch availability zone and the selected switch instance ID must be in the same availability zone.</font>",
        "zh-cn": "可用区ID。<br><b>注: <font color='blue'>选择前请确认该可用区是否支持创建ECS资源的规格,建议与其他交换机可用区不同</font></b><br><font color='red'>交换机可用区和已选择的交换机实例ID必须在同一个可用区。</font>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId"
    },
    "ECSImageId": {
      "Type": "String",
      "Label": {
        "en": "Image",
        "zh-cn": "镜像"
      },
      "Description": {
        "en": "Image ID,Please use Centos7, see detail:<b><a href='https://www.alibabacloud.com/help/en/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>",
        "zh-cn": "镜像ID, 请使用Centos7, 详见:<b><a href='https://help.aliyun.com/document_detail/112977.html' target='_blank'><font color='blue'>查找镜像</font></a></b>"
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "AssociationPropertyMetadata": {
        "InstanceType": "${ECSInstanceType}",
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      },
      "Default": "centos_7_04_64_20G_alibase_201701015.vhd"
    },
    "ECSInstanceType": {
      "Type": "String",
      "Label": {
        "en": "Instance Type",
        "zh-cn": "实例规格"
      },
      "Description": {
        "en": "<font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]",
        "zh-cn": "<font color='blue'><b>1.选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备</b></font><br><font color='blue'><b>2.可选机型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 内网带宽1Gbps 内网收发包30万PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 内网带宽1.5Gbps 内网收发包50万PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 内网带宽2.5Gbps 内网收发包80万PPS</font>]"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "ECSZoneId"
      }
    },
    "ECSDiskCategory": {
      "Type": "String",
      "Label": {
        "en": "System Disk Type",
        "zh-cn": "系统盘类型"
      },
      "Description": {
        "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]",
        "zh-cn": "<font color='blue'><b>可选值:</b></font><br>[cloud_efficiency: <font color='green'>高效云盘</font>]<br>[cloud_ssd: <font color='green'>SSD云盘</font>]<br>[cloud_essd: <font color='green'>ESSD云盘</font>]<br>[cloud: <font color='green'>普通云盘</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盘</font>]"
      },
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "LocaleKey": "DiskCategory",
        "InstanceType": "${ECSInstanceType}"
      }
    },
    "ECSSysDiskSize": {
      "Type": "Number",
      "Label": {
        "en": "System Disk Space",
        "zh-cn": "系统盘空间"
      },
      "Description": {
        "en": "System disk size, range of values: 40-500, units: GB.",
        "zh-cn": "系统盘大小, 取值范围:[40, 500], 单位:GB。"
      },
      "Default": 40,
      "MinValue": 40,
      "MaxValue": 500
    },
    "ECSPassword": {
      "Type": "String",
      "NoEcho": true,
      "Label": {
        "en": "Instance Password",
        "zh-cn": "实例密码"
      },
      "Description": {
        "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).",
        "zh-cn": "服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。"
      },
      "ConstraintDescription": {
        "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).",
        "zh-cn": "长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。"
      },
      "Default": null,
      "AssociationProperty": "ALIYUN::ECS::Instance::Password"
    },
    "KeyPairName": {
      "Type": "String",
      "Label": {
        "en": "Key Pair Name",
        "zh-cn": "密钥对名称"
      },
      "Description": {
        "en": "If it is a Windows ECS instance, ignore this parameter. The default is blank.<br>If you have filled in <font color='green'>key pair name</font>, <font color='green'>instance password< The content of /font> will still be set in the instance, but the password login method in the Linux system will be forbidden.<br><font color='red'>Please enter the name of the existing key pair. If you use the instance password Login, the key pair name does not need to be filled in</font>",
        "zh-cn": "如果是Windows ECS实例,则忽略该参数。默认为空。<br>如果已填写<font color='green'>密钥对名称</font>,<font color='green'>实例密码</font>的内容仍会被设置到实例中,但是Linux系统中的密码登录方式会被禁止。<br><font color='red'>请输入已有密钥对的名称。如使用实例密码登录,密钥对名称不需要填写</font>"
      },
      "AssociationProperty": "ALIYUN::ECS::KeyPair::KeyPairName",
      "Default": null
    },
    "PayType": {
      "Type": "String",
      "Label": {
        "en": "ECS Instance Charge Type",
        "zh-cn": "ECS付费类型"
      },
      "AssociationProperty": "ChargeType",
      "AssociationPropertyMetadata": {
        "LocaleKey": "InstanceChargeType"
      },
      "Default": "PostPaid",
      "AllowedValues": [
        "PostPaid",
        "PrePaid"
      ]
    },
    "PayPeriodUnit": {
      "Type": "String",
      "Label": {
        "en": "Pay Period Unit",
        "zh-cn": "购买资源时长周期"
      },
      "AssociationProperty": "PayPeriodUnit",
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${PayType}",
                "PostPaid"
              ]
            }
          }
        }
      },
      "Default": "Month",
      "AllowedValues": [
        "Month",
        "Year"
      ]
    },
    "PayPeriod": {
      "Type": "Number",
      "Label": {
        "en": "Period",
        "zh-cn": "购买资源时长"
      },
      "AssociationProperty": "PayPeriod",
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${PayType}",
                "PostPaid"
              ]
            }
          }
        }
      },
      "Default": 1,
      "AllowedValues": [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ]
    }
  },
  "Resources": {
    "ECSInstanceGroup": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "ZoneId": {
          "Ref": "ECSZoneId"
        },
        "VpcId": {
          "Ref": "VPC"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": {
          "Ref": "ECSImageId"
        },
        "AllocatePublicIP": "false",
        "InstanceChargeType": {
          "Ref": "PayType"
        },
        "Period": {
          "Ref": "PayPeriod"
        },
        "PeriodUnit": {
          "Ref": "PayPeriodUnit"
        },
        "InstanceType": {
          "Ref": "ECSInstanceType"
        },
        "IoOptimized": "optimized",
        "KeyPairName": {
          "Ref": "KeyPairName"
        },
        "MaxAmount": {
          "Ref": "Count"
        },
        "Password": {
          "Ref": "ECSPassword"
        },
        "SystemDiskCategory": {
          "Ref": "ECSDiskCategory"
        },
        "SystemDiskSize": {
          "Ref": "ECSSysDiskSize"
        }
      }
    },
    "ElasticIp": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "Bandwidth": {
          "Ref": "EIPBandwidth"
        },
        "InternetChargeType": {
          "Ref": "EIPInternetChargeType"
        }
      },
      "Count": {
        "Ref": "Count"
      }
    },
    "ElasticIpAssociation": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Fn::Select": [
            {
              "Ref": "ALIYUN::Index"
            },
            {
              "Fn::GetAtt": [
                "ECSInstanceGroup",
                "InstanceIds"
              ]
            }
          ]
        },
        "AllocationId": {
          "Fn::Select": [
            {
              "Ref": "ALIYUN::Index"
            },
            {
              "Ref": "ElasticIp"
            }
          ]
        }
      },
      "Count": {
        "Ref": "Count"
      }
    }
  },
  "Outputs": {
    "EipAddress": {
      "Description": "IP address of created EIP.",
      "Value": {
        "Fn::GetAtt": [
          "ElasticIp",
          "EipAddress"
        ]
      }
    },
    "SecurityGroupId": {
      "Description": "generated security group id for security group.",
      "Value": {
        "Ref": "SecurityGroup"
      }
    },
    "VSwitchId": {
      "Description": "generated security vswitch id for VPC.",
      "Value": {
        "Ref": "VSwitch"
      }
    },
    "VpcId": {
      "Description": "generated security vpc id for VPC.",
      "Value": {
        "Ref": "VPC"
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VPC",
            "ECSZoneId",
            "VSwitch",
            "SecurityGroup"
          ],
          "Label": {
            "default": "VPC "
          }
        },
        {
          "Parameters": [
            "EIPBandwidth",
            "EIPInternetChargeType"
          ],
          "Label": {
            "default": "EIP"
          }
        },
        {
          "Parameters": [
            "PayType",
            "PayPeriodUnit",
            "PayPeriod"
          ],
          "Label": {
            "default": {
              "en": "ECS PayType Configuration",
              "zh-cn": "ECS付费类型配置"
            }
          }
        },
        {
          "Parameters": [
            "ECSInstanceType",
            "ECSImageId",
            "ECSDiskCategory",
            "ECSSysDiskSize",
            "Count",
            "ECSPassword",
            "KeyPairName"
          ],
          "Label": {
            "default": "ECS"
          }
        }
      ]
    }
  }
}

场景 3 :创建或选择已有在单个ECS实例绑定多个EIP

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建指定数量的VPC内ECS实例,配备EIP,按配置计费与带宽,于指定交换机与安全组下。
  en: Provision a specified number of ECS instances within a designated VPC, equipped with Elastic IP Addresses (EIPs), billed by configuration and bandwidth usage, placed under the specified virtual switch (VSwitch) and security group.
Parameters:
  VPC:
    Type: String
    Label:
      en: VPC ID
      zh-cn: 专有网络VPC实例ID
    Description:
      en: Please search the ID starting with (vpc-xxx)from console-Virtual Private Cloud
      zh-cn: 现有虚拟专有网络的实例ID,控制台-VPC-专有网络下查询
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
  VSwitch:
    Type: String
    Label:
      en: VSwitch ID
      zh-cn: 交换机实例ID
    Description:
      en: Existing VSwitch ID, query under console-VPC-VSwitch, <font color='red'>VSwitch must be under VPC. ECS will be created under this VSwitch</font>
      zh-cn: 现有交换机ID,控制台-VPC-交换机下查询,<font color='red'>交换机必须在VPC下。ECS将创建在此交换机下</font>
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VPC}
      ZoneId: ${ECSZoneId}
  SecurityGroup:
    Type: String
    Label:
      en: Business Security Group ID
      zh-cn: 业务安全组ID
    Description:
      en: Please search the business security group ID starting with(sg-xxx)from console-ECS-Network & Security
      zh-cn: 现有业务安全组的实例ID,控制台-ECS-网络与安全-安全组下查询。<br><font color='red'>安全组必须归属在VPC下。</font>
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    AssociationPropertyMetadata:
      VpcId: ${VPC}
  EIPBandwidth:
    Type: Number
    Label:
      en: EIP Bandwidth
      zh-cn: 弹性公网带宽
    Description:
      en: 'EIP Bandwidth, Value range: [1,200], unit: Mbps.'
      zh-cn: 弹性公网地址带宽。取值范围:1~200, 单位:Mbps。
    Default: 1
    MinValue: 1
    MaxValue: 200
  EIPInternetChargeType:
    Type: String
    Label:
      en: EIP Charge Type
      zh-cn: 弹性公网地址的收费类型
    AssociationPropertyMetadata:
      LocaleKey: InternetChargeType
    Default: PayByTraffic
    AllowedValues:
      - PayByBandwidth
      - PayByTraffic
  Count:
    Type: Number
    Label:
      en: Count
      zh-cn: 数量
    Description:
      en: 'The number of ecs and eip to be created, value range: [1,140]'
      zh-cn: 需要创建的ecs和eip的数量,取值范围:[1,140]
    Default: 2
    MinValue: 1
    MaxValue: 140
  ECSZoneId:
    Type: String
    Label:
      en: VSwitch Availability Zone
      zh-cn: 交换机可用区
    Description:
      en: 'Availability zone ID.<br><b>Note: <font color=''blue''>Before selecting, please confirm whether the availability zone supports the specification of creating ECS resources. It is recommended to be different from other switch availability zones</font></b ><br><font color=''red''>The switch availability zone and the selected switch instance ID must be in the same availability zone.</font>'
      zh-cn: 可用区ID。<br><b>注: <font color='blue'>选择前请确认该可用区是否支持创建ECS资源的规格,建议与其他交换机可用区不同</font></b><br><font color='red'>交换机可用区和已选择的交换机实例ID必须在同一个可用区。</font>
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
  ECSImageId:
    Type: String
    Label:
      en: Image
      zh-cn: 镜像
    Description:
      en: Image ID,Please use Centos7, see detail:<b><a href='https://www.alibabacloud.com/help/en/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>
      zh-cn: 镜像ID, 请使用Centos7, 详见:<b><a href='https://help.aliyun.com/document_detail/112977.html' target='_blank'><font color='blue'>查找镜像</font></a></b>
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    AssociationPropertyMetadata:
      InstanceType: ${ECSInstanceType}
      SupportedImageOwnerAlias:
        - system
        - self
        - others
    Default: centos_7_04_64_20G_alibase_201701015.vhd
  ECSInstanceType:
    Type: String
    Label:
      en: Instance Type
      zh-cn: 实例规格
    Description:
      en: <font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
      zh-cn: <font color='blue'><b>1.选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备</b></font><br><font color='blue'><b>2.可选机型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 内网带宽1Gbps 内网收发包30万PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 内网带宽1.5Gbps 内网收发包50万PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 内网带宽2.5Gbps 内网收发包80万PPS</font>]
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ECSZoneId
  ECSDiskCategory:
    Type: String
    Label:
      en: System Disk Type
      zh-cn: 系统盘类型
    Description:
      en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency: <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud: <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD Cloud Disk</font>]'
      zh-cn: '<font color=''blue''><b>可选值:</b></font><br>[cloud_efficiency: <font color=''green''>高效云盘</font>]<br>[cloud_ssd: <font color=''green''>SSD云盘</font>]<br>[cloud_essd: <font color=''green''>ESSD云盘</font>]<br>[cloud: <font color=''green''>普通云盘</font>]<br>[ephemeral_ssd: <font color=''green''>本地SSD盘</font>]'
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      LocaleKey: DiskCategory
      InstanceType: ${ECSInstanceType}
  ECSSysDiskSize:
    Type: Number
    Label:
      en: System Disk Space
      zh-cn: 系统盘空间
    Description:
      en: 'System disk size, range of values: 40-500, units: GB.'
      zh-cn: 系统盘大小, 取值范围:[40, 500], 单位:GB。
    Default: 40
    MinValue: 40
    MaxValue: 500
  ECSPassword:
    Type: String
    NoEcho: true
    Label:
      en: Instance Password
      zh-cn: 实例密码
    Description:
      en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
      zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
    ConstraintDescription:
      en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
      zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
    Default: Null
    AssociationProperty: ALIYUN::ECS::Instance::Password
  KeyPairName:
    Type: String
    Label:
      en: Key Pair Name
      zh-cn: 密钥对名称
    Description:
      en: If it is a Windows ECS instance, ignore this parameter. The default is blank.<br>If you have filled in <font color='green'>key pair name</font>, <font color='green'>instance password< The content of /font> will still be set in the instance, but the password login method in the Linux system will be forbidden.<br><font color='red'>Please enter the name of the existing key pair. If you use the instance password Login, the key pair name does not need to be filled in</font>
      zh-cn: 如果是Windows ECS实例,则忽略该参数。默认为空。<br>如果已填写<font color='green'>密钥对名称</font>,<font color='green'>实例密码</font>的内容仍会被设置到实例中,但是Linux系统中的密码登录方式会被禁止。<br><font color='red'>请输入已有密钥对的名称。如使用实例密码登录,密钥对名称不需要填写</font>
    AssociationProperty: ALIYUN::ECS::KeyPair::KeyPairName
    Default: Null
  PayType:
    Type: String
    Label:
      en: ECS Instance Charge Type
      zh-cn: ECS付费类型
    AssociationProperty: ChargeType
    AssociationPropertyMetadata:
      LocaleKey: InstanceChargeType
    Default: PostPaid
    AllowedValues:
      - PostPaid
      - PrePaid
  PayPeriodUnit:
    Type: String
    Label:
      en: Pay Period Unit
      zh-cn: 购买资源时长周期
    AssociationProperty: PayPeriodUnit
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${PayType}
              - PostPaid
    Default: Month
    AllowedValues:
      - Month
      - Year
  PayPeriod:
    Type: Number
    Label:
      en: Period
      zh-cn: 购买资源时长
    AssociationProperty: PayPeriod
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${PayType}
              - PostPaid
    Default: 1
    AllowedValues:
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 7
      - 8
      - 9
Resources:
  ECSInstanceGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      ZoneId:
        Ref: ECSZoneId
      VpcId:
        Ref: VPC
      VSwitchId:
        Ref: VSwitch
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId:
        Ref: ECSImageId
      AllocatePublicIP: 'false'
      InstanceChargeType:
        Ref: PayType
      Period:
        Ref: PayPeriod
      PeriodUnit:
        Ref: PayPeriodUnit
      InstanceType:
        Ref: ECSInstanceType
      IoOptimized: optimized
      KeyPairName:
        Ref: KeyPairName
      MaxAmount:
        Ref: Count
      Password:
        Ref: ECSPassword
      SystemDiskCategory:
        Ref: ECSDiskCategory
      SystemDiskSize:
        Ref: ECSSysDiskSize
  ElasticIp:
    Type: ALIYUN::VPC::EIP
    Properties:
      Bandwidth:
        Ref: EIPBandwidth
      InternetChargeType:
        Ref: EIPInternetChargeType
    Count:
      Ref: Count
  ElasticIpAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Fn::Select:
          - Ref: ALIYUN::Index
          - Fn::GetAtt:
              - ECSInstanceGroup
              - InstanceIds
      AllocationId:
        Fn::Select:
          - Ref: ALIYUN::Index
          - Ref: ElasticIp
    Count:
      Ref: Count
Outputs:
  EipAddress:
    Description: IP address of created EIP.
    Value:
      Fn::GetAtt:
        - ElasticIp
        - EipAddress
  SecurityGroupId:
    Description: generated security group id for security group.
    Value:
      Ref: SecurityGroup
  VSwitchId:
    Description: generated security vswitch id for VPC.
    Value:
      Ref: VSwitch
  VpcId:
    Description: generated security vpc id for VPC.
    Value:
      Ref: VPC
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - VPC
          - ECSZoneId
          - VSwitch
          - SecurityGroup
        Label:
          default: 'VPC '
      - Parameters:
          - EIPBandwidth
          - EIPInternetChargeType
        Label:
          default: EIP
      - Parameters:
          - PayType
          - PayPeriodUnit
          - PayPeriod
        Label:
          default:
            en: ECS PayType Configuration
            zh-cn: ECS付费类型配置
      - Parameters:
          - ECSInstanceType
          - ECSImageId
          - ECSDiskCategory
          - ECSSysDiskSize
          - Count
          - ECSPassword
          - KeyPairName
        Label:
          default: ECS
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Locals": {
    "DS_Eip1": {
      "Type": "DATASOURCE::EIP::Address",
      "Properties": {
        "AllocationId": {
          "Ref": "EipId1"
        }
      }
    },
    "HasEip1": {
      "Type": "Eval",
      "Value": {
        "Fn::Not": {
          "Fn::Equals": [
            {
              "Fn::Length": {
                "Ref": "DS_Eip1"
              }
            },
            0
          ]
        }
      }
    },
    "DS_Eip2": {
      "Type": "DATASOURCE::EIP::Address",
      "Properties": {
        "AllocationId": {
          "Ref": "EipId2"
        }
      }
    },
    "HasEip2": {
      "Type": "Eval",
      "Value": {
        "Fn::Not": {
          "Fn::Equals": [
            {
              "Fn::Length": {
                "Ref": "DS_Eip2"
              }
            },
            0
          ]
        }
      }
    },
    "DS_Eip3": {
      "Type": "DATASOURCE::EIP::Address",
      "Properties": {
        "AllocationId": {
          "Ref": "EipId3"
        }
      }
    },
    "HasEip3": {
      "Type": "Eval",
      "Value": {
        "Fn::Not": {
          "Fn::Equals": [
            {
              "Fn::Length": {
                "Ref": "DS_Eip3"
              }
            },
            0
          ]
        }
      }
    }
  },
  "Parameters": {
    "EcsCondition": {
      "Type": "String",
      "Label": {
        "zh-cn": "是否创建ECS/Eip/Eni",
        "en": "Create an ECS/Eip/Eni"
      },
      "AllowedValues": [
        "使用已有ECS/Eip/Eni",
        "创建ECS/Eip/Eni"
      ],
      "Default": "使用已有ECS/Eip/Eni"
    },
    "EcsInstanceId": {
      "Type": "String",
      "Default": null,
      "Label": {
        "en": "ECS Instance ID",
        "zh-cn": "ECS实例ID"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceId",
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "创建ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    },
    "ECSNetworkInterfaceId": {
      "Type": "String",
      "Default": null,
      "Label": {
        "en": "ECS Network Interface ID",
        "zh-cn": "ECS弹性网卡ID"
      },
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "创建ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    },
    "EipId1": {
      "Type": "String",
      "Default": null,
      "AssociationProperty": "ALIYUN::VPC::EIP::AllocationId",
      "Label": {
        "en": "Elastic IP Address1 Instance ID",
        "zh-cn": "弹性公网IP1实例ID"
      },
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "创建ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    },
    "EipId2": {
      "Type": "String",
      "Default": null,
      "AssociationProperty": "ALIYUN::VPC::EIP::AllocationId",
      "Label": {
        "en": "Elastic IP Address2 Instance ID",
        "zh-cn": "弹性公网IP2实例ID"
      },
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "创建ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    },
    "EipId3": {
      "Type": "String",
      "Default": null,
      "AssociationProperty": "ALIYUN::VPC::EIP::AllocationId",
      "Label": {
        "en": "Elastic IP Address3 Instance ID",
        "zh-cn": "弹性公网IP3实例ID"
      },
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "创建ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    },
    "SystemDiskCategory": {
      "Default": null,
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}",
        "ZoneId": "${ZoneId}",
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "使用已有ECS/Eip/Eni"
              ]
            }
          }
        }
      },
      "Type": "String",
      "Description": {
        "zh-cn": "<font color='blue'><b>可选值:</b></font><br>[cloud_efficiency: <font color='green'>高效云盘</font>]<br>[cloud_ssd: <font color='green'>SSD云盘</font>]<br>[cloud_essd: <font color='green'>ESSD云盘</font>]<br>[cloud: <font color='green'>普通云盘</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盘</font>]",
        "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]"
      },
      "Label": {
        "zh-cn": "系统磁盘类型",
        "en": "System Disk Category"
      }
    },
    "InstancePassword": {
      "ConstraintDescription": {
        "zh-cn": "长度8-30,必须包含大写字母、小写字母、数字、特殊符号三种;特殊字符包括:()`~!@#$%^&*_-+=|{}[]:;' <>,.?/",
        "en": "Length 8-30, must contain upper case letters, lower case letters, Numbers, special symbols three; special characters include: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "Description": {
        "zh-cn": "长度8-30,必须包含大写字母、小写字母、数字、特殊符号三个;<br>特殊字符包括:()`~!@#$%^&*_-+=|{}[]:;'<>,.?/",
        "en": "The 8-30 long login password of instance, consists of the uppercase, lowercase letter and number. <br> special characters include()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "MinLength": "8",
      "Label": {
        "zh-cn": "实例密码",
        "en": "Instance Password"
      },
      "AllowedPattern": "[0-9A-Za-z\\_\\-&:;'<>,=%`~!@#\\(\\)\\$\\^\\*\\+\\|\\{\\}\\[\\]\\.\\?\\/]+$",
      "NoEcho": true,
      "Default": null,
      "MaxLength": "30",
      "Type": "String",
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "使用已有ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    },
    "InstanceType": {
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "${ZoneId}",
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "使用已有ECS/Eip/Eni"
              ]
            }
          }
        }
      },
      "Type": "String",
      "Default": null,
      "Label": {
        "zh-cn": "实例类型",
        "en": "Instance Type"
      }
    },
    "ZoneId": {
      "Default": null,
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "Type": "String",
      "Description": {
        "zh-cn": "可用区ID。<br><b>注: <font color='blue'>选择可用区前请确认该可用区是否支持创建ECS资源的规格</font></b>",
        "en": "Availability Zone ID,<br><b>note: <font color='blue'>Before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources</font></b>"
      },
      "Label": {
        "zh-cn": "可用区ID",
        "en": "Available Zone ID"
      },
      "AssociationPropertyMetadata": {
        "Visible": {
          "Condition": {
            "Fn::Not": {
              "Fn::Equals": [
                "${EcsCondition}",
                "使用已有ECS/Eip/Eni"
              ]
            }
          }
        }
      }
    }
  },
  "Resources": {
    "DS_Instances": {
      "Condition": "HasEcs",
      "Type": "DATASOURCE::ECS::Instances",
      "Properties": {
        "InstanceIds": [
          {
            "Ref": "EcsInstanceId"
          }
        ]
      }
    },
    "DS_NetworkInterfaces": {
      "Condition": "HasEcs",
      "Type": "DATASOURCE::ECS::NetworkInterfaces",
      "Properties": {
        "NetworkInterfaceIds": [
          {
            "Ref": "ECSNetworkInterfaceId"
          }
        ]
      }
    },
    "AssignPrivateIpAddresses": {
      "Type": "ALIYUN::ECS::AssignPrivateIpAddresses",
      "Properties": {
        "NetworkInterfaceId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsENI",
                "NetworkInterfaceId"
              ]
            },
            {
              "Ref": "ECSNetworkInterfaceId"
            }
          ]
        },
        "SecondaryPrivateIpAddressCount": 2
      }
    },
    "EipAssociationPrimaryPrivateIp": {
      "DependsOn": [
        "AssignPrivateIpAddresses"
      ],
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Condition": "EipAssociation1",
      "Properties": {
        "InstanceId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsENI",
                "NetworkInterfaceId"
              ]
            },
            {
              "Ref": "ECSNetworkInterfaceId"
            }
          ]
        },
        "AllocationId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "Eip1",
                "AllocationId"
              ]
            },
            {
              "Ref": "EipId1"
            }
          ]
        },
        "PrivateIpAddress": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsENI",
                "PrivateIpAddress"
              ]
            },
            {
              "Fn::Jq": [
                "First",
                ".[0].PrivateIpAddress",
                {
                  "Fn::GetAtt": [
                    "DS_NetworkInterfaces",
                    "NetworkInterfaces"
                  ]
                }
              ]
            }
          ]
        },
        "Mode": "NAT"
      }
    },
    "EipAssociationSecondaryPrivateIp1": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Condition": "EipAssociation2",
      "DependsOn": [
        "EipAssociationPrimaryPrivateIp"
      ],
      "Properties": {
        "InstanceId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsENI",
                "NetworkInterfaceId"
              ]
            },
            {
              "Ref": "ECSNetworkInterfaceId"
            }
          ]
        },
        "AllocationId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "Eip2",
                "AllocationId"
              ]
            },
            {
              "Ref": "EipId2"
            }
          ]
        },
        "PrivateIpAddress": {
          "Fn::Select": [
            "0",
            {
              "Fn::GetAtt": [
                "AssignPrivateIpAddresses",
                "PrivateIpAddresses"
              ]
            }
          ]
        },
        "Mode": "NAT"
      }
    },
    "EipAssociationSecondaryPrivateIp2": {
      "DependsOn": [
        "EipAssociationSecondaryPrivateIp1"
      ],
      "Condition": "EipAssociation3",
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsENI",
                "NetworkInterfaceId"
              ]
            },
            {
              "Ref": "ECSNetworkInterfaceId"
            }
          ]
        },
        "AllocationId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "Eip3",
                "AllocationId"
              ]
            },
            {
              "Ref": "EipId3"
            }
          ]
        },
        "PrivateIpAddress": {
          "Fn::Select": [
            "1",
            {
              "Fn::GetAtt": [
                "AssignPrivateIpAddresses",
                "PrivateIpAddresses"
              ]
            }
          ]
        },
        "Mode": "NAT"
      }
    },
    "EcsEniAttachment": {
      "DependsOn": [
        "EipAssociationPrimaryPrivateIp",
        "EipAssociationSecondaryPrivateIp1",
        "EipAssociationSecondaryPrivateIp2"
      ],
      "Type": "ALIYUN::ECS::NetworkInterfaceAttachment",
      "Properties": {
        "InstanceId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsInstance",
                "InstanceId"
              ]
            },
            {
              "Ref": "EcsInstanceId"
            }
          ]
        },
        "NetworkInterfaceId": {
          "Fn::If": [
            "CreateEcs",
            {
              "Fn::GetAtt": [
                "EcsENI",
                "NetworkInterfaceId"
              ]
            },
            {
              "Ref": "ECSNetworkInterfaceId"
            }
          ]
        }
      }
    },
    "WaitConditionHandle": {
      "Type": "ALIYUN::ROS::WaitConditionHandle",
      "Properties": {}
    },
    "WaitCondition": {
      "Type": "ALIYUN::ROS::WaitCondition",
      "Properties": {
        "Handle": {
          "Ref": "WaitConditionHandle"
        },
        "Timeout": 3720,
        "Count": 1
      }
    },
    "InitEcsEni": {
      "Type": "ALIYUN::ECS::RunCommand",
      "Properties": {
        "InstanceIds": [
          {
            "Fn::If": [
              "CreateEcs",
              {
                "Fn::GetAtt": [
                  "EcsInstance",
                  "InstanceId"
                ]
              },
              {
                "Ref": "EcsInstanceId"
              }
            ]
          }
        ],
        "Type": "RunShellScript",
        "Sync": true,
        "Timeout": 3600,
        "CommandContent": {
          "Fn::Sub": [
            "#!/bin/bash\nif [ ! -f .ros.provision ]; then\n  echo \"Name: 普通模式下实现ECS绑定多EIP(CentOS 7)\" > .ros.provision\nfi\nname=$(grep \"^Name:\" .ros.provision | awk -F':' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')\nif [[ \"$name\" != \"普通模式下实现ECS绑定多EIP(CentOS 7)\" ]]; then\n  echo \"当前实例已使用过\\\"$name\\\"教程的一键配置,不能再使用本教程的一键配置\"\n  ${WaitConditionHandle.CurlCli} --data-binary \"{\\\"status\\\": \\\"FAILURE\\\", \\\"reason\\\": \\\"The current instance has already applied the configuration of the \\\\\\\"$name\\\\\\\" tutorial, and the configuration of this tutorial can no longer be applied.\\\"}\"\n  exit 0\nfi\nsecondary_eni=`ip address show | grep eth | grep DOWN | awk -F: '{print $2}'`\nsecondary_eni_name=`eval echo \"$secondary_eni\"`\nif [[ \"$secondary_eni_name\" != \"\" ]]; then\n  echo \"#########################\"\n  echo \"# The secondary Eni is not fully configured\"\n  echo \"#########################\"\n  secondary_eni_mac=`cat /sys/class/net/\"$secondary_eni_name\"/address`\n  echo \"DEVICE=$secondary_eni_name\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"BOOTPROTO=dhcp\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"ONBOOT=yes\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"TYPE=Ethernet\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"USERCTL=yes\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"PEERDNS=no\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"IPV6INIT=no\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"PERSISTENT_DHCLIENT=yes\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"HWADDR=$secondary_eni_mac\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  echo \"DEFROUTE=no\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\"\n  systemctl restart network\nelse\n    echo \"#########################\"\n    echo \"# Secondary Eni has been configured\"\n    echo \"#########################\"\nfi\nnetmask_address=`ifconfig \"$secondary_eni_name\"| grep netmask | awk '{print $4}'`\necho \"DEVICE=$secondary_eni_name:0\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":0\necho \"TYPE=Ethernet\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":0\necho \"BOOTPROTO=static\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":0\necho \"ONBOOT=yes\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":0\necho \"IPADDR=${PrivateIpAddresses1}\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":0\necho \"NETMASK=$netmask_address\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":0\necho \"DEVICE=$secondary_eni_name:1\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":1\necho \"TYPE=Ethernet\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":1\necho \"BOOTPROTO=static\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":1\necho \"ONBOOT=yes\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":1\necho \"IPADDR=${PrivateIpAddresses2}\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":1\necho \"NETMASK=$netmask_address\" >> /etc/sysconfig/network-scripts/ifcfg-\"$secondary_eni_name\":1\nsystemctl restart network\necho \"# Secondary Eni PrivateIpAddresses has been configured\"\n${WaitConditionHandle.CurlCli} --data-binary '{\"status\": \"SUCCESS\"}'\n",
            {
              "PrivateIpAddresses1": {
                "Fn::Select": [
                  "0",
                  {
                    "Fn::GetAtt": [
                      "AssignPrivateIpAddresses",
                      "PrivateIpAddresses"
                    ]
                  }
                ]
              },
              "PrivateIpAddresses2": {
                "Fn::Select": [
                  "1",
                  {
                    "Fn::GetAtt": [
                      "AssignPrivateIpAddresses",
                      "PrivateIpAddresses"
                    ]
                  }
                ]
              }
            }
          ]
        }
      },
      "DependsOn": [
        "EcsEniAttachment"
      ]
    },
    "EcsVpc": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "192.168.0.0/16"
      }
    },
    "EcsVSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Condition": "CreateEcs",
      "Properties": {
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "CidrBlock": "192.168.1.0/24",
        "ZoneId": {
          "Ref": "ZoneId"
        }
      }
    },
    "EcsSecurityGroup": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "EcsVpc"
        }
      }
    },
    "EcsInstance": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "VpcId": {
          "Fn::GetAtt": [
            "EcsVpc",
            "VpcId"
          ]
        },
        "AllocatePublicIP": false,
        "SecurityGroupId": {
          "Ref": "EcsSecurityGroup"
        },
        "ImageId": "centos_7",
        "VSwitchId": {
          "Ref": "EcsVSwitch"
        },
        "Password": {
          "Ref": "InstancePassword"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        }
      }
    },
    "EcsENI": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::ECS::NetworkInterface",
      "Properties": {
        "VSwitchId": {
          "Ref": "EcsVSwitch"
        },
        "SecurityGroupId": {
          "Ref": "EcsSecurityGroup"
        }
      }
    },
    "Eip1": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InstanceChargeType": "Postpaid",
        "InternetChargeType": "PayByTraffic"
      }
    },
    "Eip2": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InstanceChargeType": "Postpaid",
        "InternetChargeType": "PayByTraffic"
      }
    },
    "Eip3": {
      "Condition": "CreateEcs",
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InstanceChargeType": "Postpaid",
        "InternetChargeType": "PayByTraffic"
      }
    }
  },
  "Outputs": {},
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "EcsCondition",
            "EcsInstanceId",
            "ZoneId",
            "InstanceType",
            "SystemDiskCategory",
            "InstancePassword",
            "ECSNetworkInterfaceId",
            "EipId1",
            "EipId2",
            "EipId3"
          ]
        }
      ]
    }
  },
  "Conditions": {
    "CreateEcs": {
      "Fn::Equals": [
        "创建ECS/Eip/Eni",
        {
          "Ref": "EcsCondition"
        }
      ]
    },
    "HasEcs": {
      "Fn::Equals": [
        "使用已有ECS/Eip/Eni",
        {
          "Ref": "EcsCondition"
        }
      ]
    },
    "HasEip1": {
      "Ref": "HasEip1"
    },
    "HasEip2": {
      "Ref": "HasEip2"
    },
    "HasEip3": {
      "Ref": "HasEip3"
    },
    "EipAssociation1": {
      "Fn::Or": [
        "CreateEcs",
        "HasEip1"
      ]
    },
    "EipAssociation2": {
      "Fn::Or": [
        "CreateEcs",
        "HasEip2"
      ]
    },
    "EipAssociation3": {
      "Fn::Or": [
        "CreateEcs",
        "HasEip3"
      ]
    }
  },
  "Description": {
    "zh-cn": "绑定多EIP至CentOS 7 ECS实例,通过辅助网卡实现弹性公网IP扩展。",
    "en": "Bind multiple EIPs to a CentOS 7 ECS instance via secondary network interfaces to achieve Elastic Public IP expansion."
  }
}