Amazon Elastic Compute Cloud
API Reference (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

CreateNetworkInterface

Description

Creates a network interface in the specified subnet.

Request Parameters

SubnetId

The ID of the subnet to associate with the network interface.

Type: String

Default: None

Required: Yes

PrivateIpAddress

The primary private IP address of the network interface.

Type: String

Default: None

Required: No

PrivateIpAddresses.n.PrivateIpAddress

The private IP address of the specified network interface. This parameter can be used multiple times to specify explicit private IP addresses for a network interface, but only one private IP address can be designated as primary.

You cannot specify this parameter with the PrivateIpAddresses.n.Primary value of true if you specify the PrivateIpAddress option.

Type: String

Default: None

Required: No

PrivateIpAddresses.n.Primary

Specifies whether the private IP address is the primary private IP address.

Only one IP address can be designated as primary. You cannot specify this parameter with the value of true and the PrivateIpAddresses.n.PrivateIpAddress option if you specify the PrivateIpAddress option.

Type: Boolean

Default: false

Required: No

SecondaryPrivateIpAddressCount

The number of secondary private IP addresses to assign to a network interface. When you specify a number of secondary IP addresses, AWS automatically assigns these IP addresses within the subnet's range.

The number of IP addresses you can assign to a network interface varies by instance type. For more information, see Available Instance Types in the Amazon Elastic Compute Cloud User Guide.

For a single network interface, you cannot specify this option and specify more than one private IP address using PrivateIpAddress.n.

Type: Integer

Default: None

Required: No

Description

The description of the network interface.

Type: String

Default: None

Required: No

SecurityGroupId.n

The list of security group IDs for the network interface.

Type: SecurityGroupIdSetItemType

Default: None

Required: No

Response Elements

The following elements are returned in a CreateNetworkInterfaceResponse element.

requestId

The ID of the request.

Type: xsd:string

networkInterface

The network interface that was created.

Type: NetworkInterfaceType

Examples

Example Request

This example creates an elastic network interface (ENI) in the specified subnet with a primary IP address that is automatically assigned to the network interface.

https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&SubnetId=subnet-b2a249da
&AUTHPARAMS

Example Response

<CreateNetworkInterfaceResponse xmlns='http://ec2.amazonaws.com/doc/2013-02-01/'>
 <requestId>8dbe591e-5a22-48cb-b948-dd0aadd55adf</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>
        <sourceDestCheck>true</sourceDestCheck>
        <groupSet>
            <item>
                <groupId>sg-1a2b3c4d</groupId>
                <groupName>default</groupName>
            </item>
        </groupSet>
        <tagSet/>
        <privateIpAddressesSet>
            <item>
                <privateIpAddress>10.0.2.157</privateIpAddress>
                <primary>true</primary>
            </item>
        </privateIpAddressesSet>
    </networkInterface>
</CreateNetworkInterfaceResponse>

Example Request

This example creates an elastic network interface (ENI) in the specified subnet with a primary IP address of 10.0.2.140 and four secondary private IP addresses that are automatically assigned to the network interface.

https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&PrivateIpAddresses.0.Primary=true
&PrivateIpAddresses.0.PrivateIpAddress=10.0.2.140
&SecondaryPrivateIpAddressCount=4
&SubnetId=subnet-a61dafcf
&AUTHPARAMS

Example Response

<CreateNetworkInterfaceResponse xmlns='http://ec2.amazonaws.com/doc/2013-02-01/'>
 <requestId>bd78c839-0895-4fac-a17f-98b559b6b630</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>
    </networkInterface>
</CreateNetworkInterfaceResponse>

Example Request

The following requests creates a network interface with a primary private IP address of 10.0.2.130 and two secondary IP addresses of 10.0.2.132 and 10.0.2.133.

https://ec2.amazonaws.com/?Action=CreateNetworkInterface
&PrivateIpAddresses.0.Primary=true
&PrivateIpAddresses.0.PrivateIpAddress=10.0.2.130
&PrivateIpAddresses.1.Primary=false
&PrivateIpAddresses.1.PrivateIpAddress=10.0.2.132
&PrivateIpAddresses.2.Primary=false
&PrivateIpAddresses.2.PrivateIpAddress=10.0.2.133
&SubnetId=subnet-a61dafcf
&AUTHPARAMS

Example Response

<CreateNetworkInterfaceResponse xmlns='http://ec2.amazonaws.com/doc/2013-02-01/'>
<requestId>a9565f4c-f928-4113-859b-905886d11658</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>
            <item>
                <privateIpAddress>10.0.2.133</privateIpAddress>
                <primary>false</primary>
            </item>
            <item>
                <privateIpAddress>10.0.2.132</privateIpAddress>
                <primary>false</primary>
            </item>
        </privateIpAddressesSet>
    </networkInterface> 
</CreateNetworkInterfaceResponse>