Creates an Elastic Network Interface (ENI).

Description

  • A newly created ENI is in the Available state.
  • An ENI can only be attached to a VPC-connected instance in the same zone.
  • An ENI can only be attached to one instance. Before you attach an ENI to another instance, you need to detach it from the current instance.
  • When an ENI is attached to another instance, its properties remain unchanged and its data traffic is redirected to the new instance.
  • One Alibaba Cloud account can have a maximum of 100 ENIs in a region by default. You can submit a ticket to apply for more ENIs.

Debugging

You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Name Type Required Example Description
RegionId String Yes cn-hangzhou

The ID of the region where an instance resides. You can call DescribeRegions to view the latest regions of Alibaba Cloud.

SecurityGroupId String Yes sg-c0003exxxxx

The ID of the security group to which an instance belongs. The security group and instance must be in the same VPC.

VSwitchId String Yes [vswitchid]

The ID of the VSwitch in the VPC.

Action String No CreateNetworkInterface

The operation that you want to perform. Set the value to CreateNetworkInterface.

ClientToken String No xxxxx

A client token. It is used to ensure the idempotency of requests. The value of this parameter is generated by the client and is unique among different requests. It can be a maximum of 64 characters in length. For more information, see How to ensure idempotency.

Description String No test

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

Default value: null.

NetworkInterfaceName String No eni-eniname1

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

Default value: null.

PrimaryIpAddress String No 172.17. XX.XXX

The primary private IP address of the ENI. The specified IP address must be idle within the CIDR block of the VSwitch. If an IP address is not specified, an idle IP address of the VSwitch will be selected at random.

ResourceGroupId String No rg-resourcegroupid1

The ID of the resource group.

Tag.N.Key String No test

The tag key of the ENI. Valid values of N: 1 to 20. It cannot be a null string. It can be a maximum of 64 characters in length. It cannot start with aliyun or acs:. It cannot contain http:// or https://.

Tag.N.Value String No api

The tag value of the ENI. Valid values of N: 1 to 20. It can be a null string. It can be a maximum of 128 characters in length. It cannot start with aliyun or acs:. It cannot contain http:// or https://.

Response parameters

Name Type Example Description
NetworkInterfaceId String eni-eniIxxxxx

The ENI ID.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=CreateNetworkInterface
&RegionId=cn-hangzhou 
&SecurityGroupId=sg-c0003exxxxx
&VSwitchId=[vswitchid]
&Tag.1.Key=test
&Tag.1.Value=api
&ResourceGroupId=rg-resourcegroupid1
&PrimaryIpAddress=172.17. XX.XXX
&NetworkInterfaceName=eni-eniname1
&Description=test
&ClientToken=xxxxxxxxx
&<Common request parameters>

Successful response examples

XML format

<CreateNetworkInterfaceResponse>
  <RequestId>04F0F334-1335-436C-A1D7-6C044FExxxxx</RequestId>
  <NetworkInterfaceId>eni-eniIxxxxx</NetworkInterfaceId>
</CreateNetworkInterfaceResponse>

JSON format

{
	"RequestId":"04F0F334-1335-436C-A1D7-6C044FExxxxx",
	"NetworkInterfaceId":"eni-enixxxxx"
}

Error codes

HTTP status code Error code Error message Description
403 InvalidUserType.NotSupported %s The error message returned when your account type is not supported.
403 Abs.InvalidAccount.NotFound %s The error message returned when your Alibaba Cloud account does not exist or your AccessKey has expired.
400 MissingParameter %s The error message returned when a required parameter is not specified.
403 Forbidden.NotSupportRAM %s The error message returned when RAM users are not allowed to perform this operation.
400 UnsupportedParameter %s The error message returned when a parameter is not supported.
403 Forbidden.SubUser %s The error message returned when the RAM user is not authorized to perform operations on this resource.
400 InvalidParameter %s The error message returned when the parameter format is incorrect.
400 InvalidInstanceId.MalFormed %s The error message returned when the instance ID format is incorrect.
400 InvalidOperation.InvalidEcsState %s The error message returned when the private IP address cannot be released under the instance state.
400 InvalidOperation.InvalidEniState %s The error message returned when the private IP address cannot be released under the ENI state.
400 InvalidOperation.DetachPrimaryEniNotAllowed %s The error message returned when the primary ENI cannot be detached from the instance.
404 InvalidEcsId.NotFound %s The error message returned when the specified instance ID does not exist.
404 InvalidEniId.NotFound %s The error message returned when the specified ENI ID does not exist.
404 InvalidVSwitchId.NotFound %s The error message returned when the specified VSwitch ID does not exist.
404 InvalidSecurityGroupId.NotFound %s The error message returned when the specified security group ID does not exist.
403 EniPerInstanceLimitExceeded %s The error message returned when the number of ENIs exceeds the upper limit for the specified ECS instance type.
403 InvalidOperation.AvailabilityZoneMismatch %s The error message returned when the specified VPC VSwitch, ENI, and instance do not belong to the same zone.
403 InvalidOperation.VpcMismatch %s The error message returned when the specified ENI and security group do not belong to the same VPC.
403 SecurityGroupInstanceLimitExceed %s The error message returned when the number of instances in the specified security group exceeds the upper limit.
403 InvalidSecurityGroupId.NotVpc %s The error message returned when the specified security group is not VPC-connected.
403 InvalidOperation.InvalidEniType %s The error message returned when the ENI type does not support the operation.
403 InvalidVSwitchId.IpNotEnough %s The error message returned when the number of IP addresses in the specified VSwitch is insufficient.
403 InvalidVSwitchId.IpInvalid %s The error message returned when the specified private IP address is invalid.
400 Forbidden.RegionId %s The error message returned when the function is not supported in this region.

View error codes