CreateNetworkInterface
Creates a network interface in the specified subnet.
For more information about network interfaces, see Elastic Network Interfaces in the Amazon Virtual Private Cloud User Guide.
Request Parameters
The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.
- ClientToken
-
Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.
Type: String
Required: No
- Description
-
A description for the network interface.
Type: String
Required: No
- DryRun
-
Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is
DryRunOperation
. Otherwise, it isUnauthorizedOperation
.Type: Boolean
Required: No
- InterfaceType
-
The type of network interface. The default is
interface
.Type: String
Valid Values:
efa | trunk
Required: No
- Ipv4Prefix.N
-
One or more IPv4 prefixes assigned to the network interface. You cannot use this option if you use the
Ipv4PrefixCount
option.Type: Array of Ipv4PrefixSpecificationRequest objects
Required: No
- Ipv4PrefixCount
-
The number of IPv4 prefixes that AWS automatically assigns to the network interface. You cannot use this option if you use the
Ipv4 Prefixes
option.Type: Integer
Required: No
- Ipv6AddressCount
-
The number of IPv6 addresses to assign to a network interface. Amazon EC2 automatically selects the IPv6 addresses from the subnet range. You can't use this option if specifying specific IPv6 addresses. If your subnet has the
AssignIpv6AddressOnCreation
attribute set totrue
, you can specify0
to override this setting.Type: Integer
Required: No
- Ipv6Addresses.N
-
One or more specific IPv6 addresses from the IPv6 CIDR block range of your subnet. You can't use this option if you're specifying a number of IPv6 addresses.
Type: Array of InstanceIpv6Address objects
Required: No
- Ipv6Prefix.N
-
One or more IPv6 prefixes assigned to the network interface. You cannot use this option if you use the
Ipv6PrefixCount
option.Type: Array of Ipv6PrefixSpecificationRequest objects
Required: No
- Ipv6PrefixCount
-
The number of IPv6 prefixes that AWS automatically assigns to the network interface. You cannot use this option if you use the
Ipv6Prefixes
option.Type: Integer
Required: No
- PrivateIpAddress
-
The primary private IPv4 address of the network interface. If you don't specify an IPv4 address, Amazon EC2 selects one for you from the subnet's IPv4 CIDR range. If you specify an IP address, you cannot indicate any IP addresses specified in
privateIpAddresses
as primary (only one IP address can be designated as primary).Type: String
Required: No
- PrivateIpAddresses.N
-
One or more private IPv4 addresses.
Type: Array of PrivateIpAddressSpecification objects
Required: No
- SecondaryPrivateIpAddressCount
-
The number of secondary private IPv4 addresses to assign to a network interface. When you specify a number of secondary IPv4 addresses, Amazon EC2 selects these IP addresses within the subnet's IPv4 CIDR range. You can't specify this option and specify more than one private IP address using
privateIpAddresses
.The number of IP addresses you can assign to a network interface varies by instance type. For more information, see IP Addresses Per ENI Per Instance Type in the Amazon Virtual Private Cloud User Guide.
Type: Integer
Required: No
- SecurityGroupId.N
-
The IDs of one or more security groups.
Type: Array of strings
Required: No
- SubnetId
-
The ID of the subnet to associate with the network interface.
Type: String
Required: Yes
- TagSpecification.N
-
The tags to apply to the new network interface.
Type: Array of TagSpecification objects
Required: No
Response Elements
The following elements are returned by the service.
- clientToken
-
The token to use to retrieve the next page of results. This value is
null
when there are no more results to return.Type: String
- networkInterface
-
Information about the network interface.
Type: NetworkInterface object
- requestId
-
The ID of the request.
Type: String
Errors
For information about the errors that are common to all actions, see Common client error codes.
Examples
Example 1
This example creates a network interface in the specified subnet with a primary IPv4 address that is automatically selected by Amazon EC2.
Sample Request
https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&SubnetId=subnet-b2a249da
&AUTHPARAMS
Sample Response
<CreateNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>8dbe591e-5a22-48cb-b948-example</requestId>
<networkInterface>
<networkInterfaceId>eni-cfca76a6</networkInterfaceId>
<subnetId>subnet-b2a249da</subnetId>
<vpcId>vpc-c31dafaa</vpcId>
<availabilityZone>ap-southeast-1b</availabilityZone>
<description/>
<ownerId>251839141158</ownerId>
<requesterManaged>false</requesterManaged>
<status>available</status>
<macAddress>02:74:b0:72:79:61</macAddress>
<privateIpAddress>10.0.2.157</privateIpAddress>
<privateDnsName>ip-10-0-2-157.ap-southeast-1.compute.internal</privateDnsName>
<sourceDestCheck>true</sourceDestCheck>
<groupSet>
<item>
<groupId>sg-1a2b3c4d</groupId>
<groupName>default</groupName>
</item>
</groupSet>
<tagSet/>
<privateIpAddressesSet>
<item>
<privateIpAddress>10.0.2.157</privateIpAddress>
<privateDnsName>ip-10-0-2-157.ap-southeast-1.compute.internal</privateDnsName>
<primary>true</primary>
</item>
</privateIpAddressesSet>
<ipv6AddressesSet/>
</networkInterface>
</CreateNetworkInterfaceResponse>
Example 2
This example creates a network interface in the specified subnet with a primary
IPv4 address of 10.0.2.140
and four secondary private IPv4
addresses that are automatically selected by Amazon EC2.
Sample Request
https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&PrivateIpAddresses.1.Primary=true
&PrivateIpAddresses.1.PrivateIpAddress=10.0.2.140
&SecondaryPrivateIpAddressCount=4
&SubnetId=subnet-a61dafcf
&AUTHPARAMS
Sample Response
<CreateNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>bd78c839-0895-4fac-a17f-example</requestId>
<networkInterface>
<networkInterfaceId>eni-1bcb7772</networkInterfaceId>
<subnetId>subnet-a61dafcf</subnetId>
<vpcId>vpc-c31dafaa</vpcId>
<availabilityZone>ap-southeast-1b</availabilityZone>
<description/>
<ownerId>251839141158</ownerId>
<requesterManaged>false</requesterManaged>
<status>pending</status>
<macAddress>02:74:b0:70:7f:1a</macAddress>
<privateIpAddress>10.0.2.140</privateIpAddress>
<sourceDestCheck>true</sourceDestCheck>
<groupSet>
<item>
<groupId>sg-1a2b3c4d</groupId>
<groupName>default</groupName>
</item>
</groupSet>
<tagSet/>
<privateIpAddressesSet>
<item>
<privateIpAddress>10.0.2.140</privateIpAddress>
<primary>true</primary>
</item>
<item>
<privateIpAddress>10.0.2.172</privateIpAddress>
<primary>false</primary>
</item>
<item>
<privateIpAddress>10.0.2.169</privateIpAddress>
<primary>false</primary>
</item>
<item>
<privateIpAddress>10.0.2.170</privateIpAddress>
<primary>false</primary>
</item>
<item>
<privateIpAddress>10.0.2.171</privateIpAddress>
<primary>false</primary>
</item>
</privateIpAddressesSet>
<ipv6AddressesSet/>
</networkInterface>
</CreateNetworkInterfaceResponse>
Example 3
This example creates a network interface with a primary private IPv4 address of 10.0.2.130 and two secondary IPv4 addresses of 10.0.2.132 and 10.0.2.133.
Sample Request
https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&PrivateIpAddresses.1.Primary=true
&PrivateIpAddresses.1.PrivateIpAddress=10.0.2.130
&PrivateIpAddresses.2.Primary=false
&PrivateIpAddresses.2.PrivateIpAddress=10.0.2.132
&PrivateIpAddresses.3.Primary=false
&PrivateIpAddresses.3.PrivateIpAddress=10.0.2.133
&SubnetId=subnet-a61dafcf
&AUTHPARAMS
Example 4
This example creates a network interface with a primary private IPv4 address of 10.0.2.130 and two IPv6 addresses that are selected by Amazon EC2.
Sample Request
https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&PrivateIpAddresses.1.Primary=true
&PrivateIpAddresses.1.PrivateIpAddress=10.0.2.130
&Ipv6AddressCount=2
&SubnetId=subnet-a61dafcf
&AUTHPARAMS
Sample Response
<CreateNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>a9565f4c-f928-4113-859b-example</requestId>
<networkInterface>
<networkInterfaceId>eni-41c47828</networkInterfaceId>
<subnetId>subnet-a61dafcf</subnetId>
<vpcId>vpc-c31dafaa</vpcId>
<availabilityZone>ap-southeast-1b</availabilityZone>
<description/>
<ownerId>251839141158</ownerId>
<requesterManaged>false</requesterManaged>
<status>pending</status>
<macAddress>02:74:b0:78:bf:ab</macAddress>
<privateIpAddress>10.0.2.130</privateIpAddress>
<sourceDestCheck>true</sourceDestCheck>
<groupSet>
<item>
<groupId>sg-188d9f74</groupId>
<groupName>default</groupName>
</item>
</groupSet>
<tagSet/>
<privateIpAddressesSet>
<item>
<privateIpAddress>10.0.2.130</privateIpAddress>
<primary>true</primary>
</item>
</privateIpAddressesSet>
<ipv6AddressesSet>
<item>
<ipv6Address>2001:db8:1234:1a00::123</ipv6Address>
</item>
<item>
<ipv6Address>2001:db8:1234:1a00::456</ipv6Address>
</item>
</ipv6AddressesSet>
</networkInterface>
</CreateNetworkInterfaceResponse>
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: