I am trying to delete some network interfaces not used in aws via aws cli. To get this list of network interfaces, i run this:
aws ec2 describe-network-interfaces --filters Name=status,Values=available --query "NetworkInterfaces[].NetworkInterfaceId" --output json
Then, I need to pass the "NetworkInterfaceId" value to delete-network-interface like this:
aws ec2 delete-network-interface --network-interface-id $(aws ec2 describe-network-interfaces --filters Name=status,Values=available --region eu-west-1 --query "NetworkInterfaces[].NetworkInterfaceId" --output text) --region eu-west-1
This only delete one ENI, only the first.
I have tried getting the --generate-cli-skeleton but the output for describe-network-interfaces give me a list of Ids, but the input json skeleton for delete-network-interface only accepts a string.
Some ideas here? Help is much appreciated. Thanks in advance.