ALIYUN::ECS::NetworkInterface is used to create an elastic network interface (ENI).

Syntax

{
  "Type": "ALIYUN::ECS::NetworkInterface",
  "Properties": {
    "Description": String,
    "SecurityGroupId": String,
    "PrimaryIpAddress": String,
    "ResourceGroupId": String,
    "VSwitchId": String,
    "NetworkInterfaceName": String,
    "SecurityGroupIds": List,
    "PrivateIpAddresses": List
  }
}

Properties

Property Type Required Editable Description Constraint
ResourceGroupId String No No The ID of the resource group to which the instance belongs. None
SecurityGroupId String No Yes The ID of the security group to which the instance belongs. The security group and the instance must be in the same VPC. None
VSwitchId String Yes No The ID of the VSwitch in the VPC. None
Description String No Yes The description of the ENI.

The description must be 2 to 256 characters in length and cannot start with http:// or https://.

This parameter is empty by default.

NetworkInterfaceName String No Yes The name of the ENI.

The name must be 2 to 128 characters in length. The name must start with a letter and cannot start with http:// or https://. It can contain letters, digits, colons (:), underscores (_), and hyphens (-).

This parameter is empty by default.

PrimaryIpAddress String No No The primary private IP address of the ENI. The specified IP address must be available within the CIDR block of the VSwitch. If this parameter is not specified, an available IP address in the VSwitch CIDR block is selected at random.
SecurityGroupIds List No Yes The IDs of multiple security groups to which the ENI belongs. The security group and the ENI must be in the same VPC.
Note You cannot specify both SecurityGroupId and SecurityGroupIds.
PrivateIpAddresses List No No One or more secondary private IP addresses selected from the CIDR block of the VSwitch that hosts the ENI. Valid values of the number of IP addresses that can be assigned to the ENI:
  • When the ENI is in the Available state, the valid values are 1 to 10.
  • When the ENI is in the InUse state, the valid values depends on the instance type. For more information, see Instance families.

Response parameters

Fn::GetAtt

  • NetworkInterfaceId: the ID of the ENI.
  • MacAddress: the MAC address of the ENI.
  • PrivateIpAddresses: the primary private IP addresses assigned to the ENI.
  • SecondaryPrivateIpAddresses: all secondary private IP addresses assigned to the ENI.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Description": {
      "Type": "String",
      "Description": "Description of your ENI. It is a string of [2, 256] English or Chinese characters."
    },
    "ResourceGroupId": {
      "Type": "String",
      "Description": "Resource group id."
    },
    "SecurityGroupId": {
      "Type": "String",
      "Description": "The ID of the security group that the ENI joins. The security group and the ENI must be in a same VPC."
    },
    "VSwitchId": {
      "Type": "String",
      "Description": "VSwitch ID of the specified VPC. Specifies the switch ID for the VPC."
    },
    "NetworkInterfaceName": {
      "Type": "String",
      "Description": "Name of your ENI. It is a string of [2, 128]  Chinese or English characters. It must begin with a letter and can contain numbers, underscores (_), colons (:), or hyphens (-)."
    },
    "PrimaryIpAddress": {
      "Type": "String",
      "Description": "The primary private IP address of the ENI.  The specified IP address must have the same Host ID as the VSwitch. If no IP addresses are specified, a random network ID is assigned for the ENI."
    }
  },
  "Resources": {
    "EniInstance": {
      "Type": "ALIYUN::ECS::NetworkInterface",
      "Properties": {
        "Description": {
          "Ref": "Description"
        },
        "ResourceGroupId": {
          "Ref": "ResourceGroupId"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "NetworkInterfaceName": {
          "Ref": "NetworkInterfaceName"
        },
        "PrimaryIpAddress": {
          "Ref": "PrimaryIpAddress"
        }
      }
    }
  },
  "Outputs": {
    "PrivateIpAddress": {
      "Description": "The private ip address of your Network Interface.",
      "Value": {
        "Fn::GetAtt": [
          "EniInstance",
          "PrivateIpAddress"
        ]
      }
    },
    "MacAddress": {
      "Description": "The MAC address of your Network Interface.",
      "Value": {
        "Fn::GetAtt": [
          "EniInstance",
          "MacAddress"
        ]
      }
    },
    "NetworkInterfaceId": {
      "Description": "ID of your Network Interface.",
      "Value": {
        "Fn::GetAtt": [
          "EniInstance",
          "NetworkInterfaceId"
        ]
      }
    }
  }
}

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Description:
    Type: String
    Description: >-
      Description of your ENI. It is a string of [2, 256] English or Chinese
      characters.
  ResourceGroupId:
    Type: String
    Description: Resource group id.
  SecurityGroupId:
    Type: String
    Description: >-
      The ID of the security group that the ENI joins. The security group and
      the ENI must be in a same VPC.
  VSwitchId:
    Type: String
    Description: VSwitch ID of the specified VPC. Specifies the switch ID for the VPC.
  NetworkInterfaceName:
    Type: String
    Description: >-
      Name of your ENI. It is a string of [2, 128]  Chinese or English
      characters. It must begin with a letter and can contain numbers,
      underscores (_), colons (:), or hyphens (-).
  PrimaryIpAddress:
    Type: String
    Description: >-
      The primary private IP address of the ENI.  The specified IP address must
      have the same Host ID as the VSwitch. If no IP addresses are specified, a
      random network ID is assigned for the ENI.
Resources:
  EniInstance:
    Type: 'ALIYUN::ECS::NetworkInterface'
    Properties:
      Description:
        Ref: Description
      ResourceGroupId:
        Ref: ResourceGroupId
      SecurityGroupId:
        Ref: SecurityGroupId
      VSwitchId:
        Ref: VSwitchId
      NetworkInterfaceName:
        Ref: NetworkInterfaceName
      PrimaryIpAddress:
        Ref: PrimaryIpAddress
Outputs:
  PrivateIpAddress:
    Description: The private ip address of your Network Interface.
    Value:
      'Fn::GetAtt':
        - EniInstance
        - PrivateIpAddress
  MacAddress:
    Description: The MAC address of your Network Interface.
    Value:
      'Fn::GetAtt':
        - EniInstance
        - MacAddress
  NetworkInterfaceId:
    Description: ID of your Network Interface.
    Value:
      'Fn::GetAtt':
        - EniInstance
        - NetworkInterfaceId