You can call this operation to create an Elastic Network Interface (ENI).

Description

  • The newly created ENI is in the Available state.
  • An ENI can be attached only to a VPC-type instance that is in the same zone as the ENI.
  • An ENI can be attached only to one instance. Before attaching an ENI to another instance, you must detach the ENI from the current instance.
  • When an ENI is attached to another instance, its properties remain unchanged and the data traffic is redirected to the new instance.
  • By default, an Alibaba Cloud account can create a maximum of 100 ENIs in a region. You can submit a ticket to apply for a higher quota.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No CreateNetworkInterface

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

RegionId String Yes cn-hangzhou

The ID of the region where the instance resides. You can call the DescribeRegions operation to query the most recent region list.

VSwitchId String Yes vsw-bp1s5fnvk4gn2tws03***

The ID of the VSwitch in the specified VPC.

Tag.N.Key String No test

The key of tag N that is bound to the ENI. Valid values of N: 1 to 20. It cannot be an empty string. It can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

Tag.N.Value String No api

The value of tag N that is bound to the ENI. Valid values of N: 1 to 20. It can be an empty string. It can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

ResourceGroupId String No rg-bp67acfmxazb4ph***

The ID of the resource group.

PrimaryIpAddress String No 172.17.**. ***

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 assigned at random.

SecurityGroupId String No sg-bp1fg655nh68xyz9i***

The ID of the security group. The security group and the ENI must belong to the same VPC.

SecurityGroupIds.N RepeatList No sg-bp1fg655nh68xyz9i***

The ID of security group N. The security groups and the ENI must belong to the same VPC. The valid values of N are based on the maximum number of security groups to which an ENI can be added. For more information, see Limits.

Note You cannot specify both SecurityGroupId and SecurityGroupIds.N at the same time.
NetworkInterfaceName String No eni-eniname1

The name of the ENI. The name 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 (-).

This parameter is empty by default.

Description String No test

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.

PrivateIpAddress.N RepeatList No 172.***. ***.177

Specifies secondary private IP address N of the ENI. This IP address must be an available IP address in the CIDR block of the VSwitch to which the ENI belongs. Valid values of N: [0,10].

Note You cannot specify both PrivateIpAddress.N and SecondaryPrivateIpAddressCount at the same time.
SecondaryPrivateIpAddressCount Integer No 1

The number of private IP addresses that can be created automatically by ECS.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

The client token that is used to ensure the idempotence of the request. You can use your client to generate a value of the parameter, but you must ensure that it is unique among different requests. The ClientToken parameter can only contain ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

NetworkInterfaceId String eni-bp14v2sdd3v8htlnm***

The ID of the ENI.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=CreateNetworkInterface
&RegionId=cn-hangzhou
&SecurityGroupIds.1=sg-bp1fg655nh68xyz9i***
&SecurityGroupIds.2=sg-bp67acfmxazb4ph***
&VSwitchId=vsw-bp1s5fnvk4gn2tws03***
&Tag.1.Key=test
&Tag.1.Value=api
&ResourceGroupId=rg-bp67acfmxazb4ph***
&PrimaryIpAddress=172.17. **. ***
&NetworkInterfaceName=eni-eniname1	
&Description=test
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

HTTP status code Error code Error message Description
403 InvalidUserType.NotSupported %s The error message returned because the current account does not support this operation.
403 Abs.InvalidAccount.NotFound %s The error message returned because your Alibaba Cloud account does not exist or your AccessKey pair has expired.
400 MissingParameter %s The error message returned because a required parameter is not specified.
403 Forbidden.NotSupportRAM %s The error message returned because RAM users are not allowed to perform this operation.
400 UnsupportedParameter %s The error message returned because a specific parameter is not supported.
403 Forbidden.SubUser %s The error message returned because you are not authorized to perform operations on this resource. Contact the owner of the Alibaba Cloud account for authorization.
400 InvalidParameter %s The error message returned because the specified parameter is invalid.
400 InvalidInstanceID.Malformed %s The error message returned because the InstanceId parameter value is invalid.
400 InvalidOperation.InvalidEcsState %s The error message returned because the operation is not supported while the instance is in the current state.
400 InvalidOperation.InvalidEniState %s The error message returned because the operation is not supported while the ENI is in the current state.
400 InvalidOperation.DetachPrimaryEniNotAllowed %s The error message returned because the primary ENI is detached from the instance.
404 InvalidEcsId.NotFound %s The error message returned because the specified instance ID does not exist.
404 InvalidEniId.NotFound %s The error message returned because the specified ENI ID does not exist.
404 InvalidVSwitchId.NotFound %s The error message returned because the specified VSwitch ID does not exist.
404 InvalidSecurityGroupId.NotFound %s The error message returned because the specified security group ID does not exist.
403 MaxEniCountExceeded %s The error message returned because the maximum number of ENIs that can be managed has been reached.
403 EniPerInstanceLimitExceeded %s The error message returned because the maximum number of ENIs that can be attached to an instance has been reached.
403 InvalidOperation.AvailabilityZoneMismatch %s The error message returned because this operation is invalid.
403 InvalidOperation.VpcMismatch %s The error message returned because this operation is invalid. Check whether the VPC in the operation corresponds to other parameters.
403 SecurityGroupInstanceLimitExceed %s The error message returned because the maximum number of instances in the specified security group has been reached.
403 InvalidSecurityGroupId.NotVpc %s The error message returned because the SecurityGroupId parameter value is invalid and the network type of the security group is not VPC.
403 InvalidOperation.InvalidEniType %s The error message returned because the current ENI type does not support this operation.
403 InvalidVSwitchId.IpNotEnough %s The error message returned because IP addresses in the specified VSwitch are insufficient.
403 InvalidVSwitchId.IpInvalid %s The error message returned because the specified private IP address is invalid.
400 Forbidden.RegionId %s The error message returned because the service is unavailable in the current region.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The error message returned because the resource group does not exist.
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. The error message returned because a tag with the identical key already exists.
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. The error message returned because the specified Tag.N.Key parameter is invalid.
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. The error message returned because the specified Tag.N.Value parameter is invalid.
403 QuotaExceed.Tags %s The error message returned because the maximum number of tags has been reached.
403 InvalidIp.Address %s The error message returned because the specified IPv6 address is invalid.
403 InvalidIp.IpRepeated %s The error message returned because the specified IP address already exists.
400 InvalidPrivateIpAddress.Duplicated Specified private IP address is duplicated. The error message returned because the specified private IP address is already in use. Try another IP address.

For a list of error codes, visit the API Error Center.