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"
            ]
          }
        }
      }
    }