ALIYUN::ECS::AssignPrivateIpAddresses is used to assign one or more secondary private IP addresses to an ENI. You can specify private IP addresses within the CIDR block of the vSwitch that hosts the ENI. You can also specify the number of private IP addresses for ECS to assign them automatically.

Syntax

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

Properties

Name Type Required Editable Description Validity
NetworkInterfaceId String Yes No The ID of the ENI. None
SecondaryPrivateIpAddressCount Integer No No The number of private IP addresses assigned to the ENI. None
PrivateIpAddresses List No No The list of one or more secondary private IP addresses selected from the CIDR block of the vSwitch that hosts the ENI. When the ENI is in the Available state, up to 10 IP addresses can be specified. When the ENI is in the InUse state, the number of IP addresses that can be specified depends on the instance type. For more information, see Overview of instance families. To assign secondary private IP addresses, you must specify either the PrivateIpAddress parameter or the SecondaryPrivateIpAddressCount parameter. But you cannot specify both of them.

Response parameters

Fn::GetAtt

  • NetworkInterfaceId: the ID of the ENI.
  • PrivateIpAddresses: the secondary private IP addresses assigned to the ENI.

Examples

  • YAMLformat

    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
  • JSONformat

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