ALIYUN::ECS::AssignPrivateIpAddresses类型用于为一块弹性网卡分配一个或多个辅助私有IP地址。您可以为网卡指定所属交换机(vSwitch)的CIDR私有IP地址,也可以通过指定私有网络地址数量自动创建私有IP地址。

语法

{
  "Type": "ALIYUN::ECS::AssignPrivateIpAddresses",
  "Properties": {
    "NetworkInterfaceId": String,
    "SecondaryPrivateIpAddressCount": Integer,
    "PrivateIpAddresses": List
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
NetworkInterfaceId String 弹性网卡ID。 无。
SecondaryPrivateIpAddressCount Integer 指定的私有IP地址数量。 无。
PrivateIpAddresses List 弹性网卡所属虚拟交换机的CIDR地址段中的一个或多个辅助私有IP地址。 弹性网卡处于可用(Available)状态时,可以设置的IP数量为:1~10个。弹性网卡处于已绑定(InUse)状态时,可以设置的IP数量将受限于实例规格,详情请参见实例规格族。分配辅助私有IP地址时,不能同时指定参数PrivateIpAddress和参数SecondaryPrivateIpAddressCount。

返回值

Fn::GetAtt

  • NetworkInterfaceId:弹性网卡ID。
  • PrivateIpAddresses:辅助私有IP地址。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      NetworkInterfaceId:
        Type: String
        Description: The ID of the ENI.
      SecondaryPrivateIpAddressCount:
        Type: Number
        Description: The specified number of private IP addresses to be assigned by the ECS instance.
        MinValue: 0
    Resources:
      AssignPrivateIpAddresses:
        Type: ALIYUN::ECS::AssignPrivateIpAddresses
        Properties:
          NetworkInterfaceId:
            Ref: NetworkInterfaceId
          SecondaryPrivateIpAddressCount: 0
    Outputs:
      NetworkInterfaceId:
        Description: The ID of the ENI.
        Value:
          Fn::GetAtt:
            - AssignPrivateIpAddresses
            - NetworkInterfaceId
      PrivateIpAddresses:
        Description: Assigned private ip addresses.
        Value:
          Fn::GetAtt:
            - AssignPrivateIpAddresses
            - PrivateIpAddresses
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "NetworkInterfaceId": {
          "Type": "String",
          "Description": "The ID of the ENI."
        },
        "SecondaryPrivateIpAddressCount": {
          "Type": "Number",
          "Description": "The specified number of private IP addresses to be assigned by the ECS instance.",
          "MinValue": 0
        }
      },
      "Resources": {
        "AssignPrivateIpAddresses": {
          "Type": "ALIYUN::ECS::AssignPrivateIpAddresses",
          "Properties": {
            "NetworkInterfaceId": {
              "Ref": "NetworkInterfaceId"
            },
            "SecondaryPrivateIpAddressCount": 0
          }
        }
      },
      "Outputs": {
        "NetworkInterfaceId": {
          "Description": "The ID of the ENI.",
          "Value": {
            "Fn::GetAtt": [
              "AssignPrivateIpAddresses",
              "NetworkInterfaceId"
            ]
          }
        },
        "PrivateIpAddresses": {
          "Description": "Assigned private ip addresses.",
          "Value": {
            "Fn::GetAtt": [
              "AssignPrivateIpAddresses",
              "PrivateIpAddresses"
            ]
          }
        }
      }
    }