Why can’t I delete my elastic network interface?

3 minute read
1

I want to delete an elastic network interface that I no longer use from an Amazon Virtual Private Machine (Amazon VPC)?

Short description

If a resource is using the elastic network interface, then you can't delete the elastic network interface. To resolve this issue, identify the resource that's using the elastic network interface and delete the resource if it's no longer required. After you delete the associated resource, you can delete the elastic network interface.

If you try to delete an elastic network interface that's assigned to or owned by a running resource, then you see the following API error:

"Error: An error occurred (InvalidParameterValue) when calling the DeleteNetworkInterface operation: Network interface 'eni-xxxxxxxxxxxxxxxxx' is currently in use."

A requester-managed network interface is a network interface that an AWS service creates in your Amazon VPC for you. When you delete a resource that's associated with a requester-managed network interface, the AWS service detaches the network interface and deletes it. If the AWS service detached the network interface but didn't delete it, then you can delete the detached network interface.

If you try to detach an elastic network Interface that an AWS managed service created and owns, then you see the following API error:

"Error: An error occurred (AuthFailure) when calling the DetachNetworkInterface operation: You do not have permission to access the specified resource."

Resolution

To delete the elastic network interface, use either AWS Command Line Interface (AWS CLI) commands or the Amazon Elastic Compute Cloud (Amazon EC2) console.

Use AWS CLI commands

1.    Note the elastic network interface ID.

2.    To see more information about the resource, use AWS CloudShell or the AWS CLI to run the describe-network-interfaces command. Replace ENI_ID with the elastic network interface ID, in the format eni-xxxxxxxxxxxxxxxxx. Replace region_name with the AWS Region where your elastic network interface is located. For example, us-west-2.

$ aws ec2 describe-network-interfaces --filters Name=network-interface-id,Values=ENI_ID --region region_name

3.    In the command output, review the Description to find the resource that the elastic network interface is attached to.

4.    If you don't need the associated resource, then delete the resource.

5.    Delete the elastic network interface.

Use the Amazon EC2 console

1.    Open the Amazon EC2 console in the same AWS Region as the elastic network interface that you want to delete.

2.    Choose Network interfaces.

3.    Search for the ID of the elastic network interface that you're deleting.

4.    Select the elastic network interface, and then choose the Details tab.

5.    Important: Review the Description to find the resource that the elastic network interface is attached to.

6.    If you no longer use the corresponding AWS service or resource, then delete the resource that's associated with the service.

7.    Delete the elastic network interface.

Note: If the resource is an AWS Lambda function, then AWS Lambda automatically deletes the network interface within 24 hours after deleting the function.

Related Information

Requester-managed network interfaces

Elastic network interfaces

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago