So I want to clean up Elastic Network Interfaces (ENIs) that were created for testing and no longer needed, and I want to use AWS CLI to do that.
For me, I know that all unused ENIs will have their status as “available”. So I will find all those ENIs and will delete them.
➜ aws ec2 describe-network-interfaces --filters Name=status,Values=available \ --query 'NetworkInterfaces[].{NetworkInterfaceId:NetworkInterfaceId,Description:Description}' [ { "NetworkInterfaceId": "eni-0dc616df583312345", "Description": "2nd nic in 2b az" }, { "NetworkInterfaceId": "eni-0bf98b53cf1b12345", "Description": "2nd nic" }, { "NetworkInterfaceId": "eni-034bcff8ceef12345", "Description": "test-eni" }, { "NetworkInterfaceId": "eni-09adbc3a20c912345", "Description": "Test 2nd eni on custom subnet 2a AZ" } ] Next, I need to feed each of the values of “NetworkInterfaceId” to the delete command aws ec2 delete-network-interface, which takes only 1 NetworkInterfaceId at a time....