Attaches a network interface to an instance.
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
attach-network-interface
--device-index <value>
[--dry-run | --no-dry-run]
--instance-id <value>
--network-interface-id <value>
[--network-card-index <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
--device-index
(integer)
The index of the device for the network interface attachment.
--dry-run
| --no-dry-run
(boolean)
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
.
--instance-id
(string)
The ID of the instance.
--network-interface-id
(string)
The ID of the network interface.
--network-card-index
(integer)
The index of the network card. Some instance types support multiple network cards. The primary network interface must be assigned to network card index 0. The default is network card index 0.
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
See ‘aws help’ for descriptions of global parameters.
Example 1: To attach a network interface to an instance
The following attach-network-interface
example attaches the specified network interface to the specified instance.
aws ec2 attach-network-interface \
--network-interface-id eni-0dc56a8d4640ad10a \
--instance-id i-1234567890abcdef0 \
--device-index 1
Output:
{
"AttachmentId": "eni-attach-01a8fc87363f07cf9"
}
For more information, see Elastic network interfaces in the Amazon EC2 User Guide.
Example 2: To attach a network interface to an instance with multiple network cards
The following attach-network-interface
example attaches the specified network interface to the specified instance and network card.
aws ec2 attach-network-interface \
--network-interface-id eni-07483b1897541ad83 \
--instance-id i-01234567890abcdef \
--network-card-index 1 \
--device-index 1
Output:
{
"AttachmentId": "eni-attach-0fbd7ee87a88cd06c"
}
For more information, see Elastic network interfaces in the Amazon EC2 User Guide.
AttachmentId -> (string)
The ID of the network interface attachment.
NetworkCardIndex -> (integer)
The index of the network card.