Can not remove or detach network interface

0

I used k8s, eks, cloudformation stacks etc.

Now I can't delete the remaining network interface EVEN under the root account. I read that I have to search for related resources, such as the VPC, routing tables etc., and try to delete them first. I tried. Most of them couldn't be deleted because they were complaining that the network interface exists haha :) I also try to detach it, but always got errors. I have no elastic IP attached. I spent like 3 hours trying to remove this network interface and its related resources, nothing helped so far. I also tried to use the aws cli but the same results. I'm just getting an error: Failed to detach the network interface. API error: "You do not have permission to access the specified resource." I also tried to use --force with cli, didn't help. I can't delete, and can't detach the interface no matter what I do.

What should I even do? To me it seems really weird that I can't do anything even from my root user.

AndyN
asked 5 months ago298 views
1 Answer
0

Hello.

I think you need to delete the resource that is using the network interface.
For example, typical resources include ALB, Lambda connected to VPC, and EC2.
First you need to find the resource that uses ENI.
If you look at the ENI description column, there may be hints written there.

I think it will be easier to see if you run the following command with CloudShell etc.

SUBNETID=subnet-yyyyyyyyyy

aws ec2 describe-network-interfaces\
 --filters Name=subnet-id,Values="$SUBNETID"\
 --query 'NetworkInterfaces[].{
     PrivateIpAddress:PrivateIpAddress,
     PublicIp:Association.PublicIp
     Name:TagSet[?Key==`Name`]|[0].Value,
     Description:Description,
     InstanceId:Attachment.InstanceId,
     NetworkInterfaceId:NetworkInterfaceId,
     Status:Status
 }'\
  --output json\
  | jq -r '
    .[] | [.PrivateIpAddress, .PublicIp, .Description, .Name,  .InstanceId, .NetworkInterfaceId, .Status] | @csv'\
  | sort -V -t "," -k 1
profile picture
EXPERT
answered 5 months ago
  • I did check all the related resources and did try to delete them, as I mentioned in the post. Nothing helped.

  • By the way, which resource is the ENI linked to that cannot be deleted?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions