ReplacePrimaryNetworkInterface#

Description#

Change the primary network interface of an instance.

Use cases:

  • Replace the primary network interface created in a virtual switch with any network interface.

  • Replace the primary network interface created in a subnet with any network interface from the same VPC.

  • Replace the primary network interface created in a subnet with any unattached network interface provided that the instance have not any other attached interfaces from other subnets.

Note

The network interface to be used instead of the primary one should be:

  • in the same availability zone as the source one;

  • created in a subnet;

  • not attached to any instance.

Important

You can replace the primary network interface only when the instance is stopped.

Request Parameters#

  • InstanceId — The ID of the instance.

    • Type: String

    • Required: Yes

  • NetworkInterfaceId — The ID of the new primary network interface.

    • Type: String

    • Required: Yes

Response Elements#

  • attachmentId — The ID of the attachment.

    • Type: String

  • requestId — The ID of the request.

    • Type: String

  • returnTrue is returned, if the request is successful, and an error otherwise.

    • Type: Boolean

Examples#

c2-ec2 ReplacePrimaryNetworkInterface InstanceId i-12345678 NetworkInterfaceId eni-12345678