#!/usr/bin/env bash

# Get network interface IDs for VPC endpoints
NETWORK_INTERFACE_IDS=$(aws ec2 describe-vpc-endpoints --query 'VpcEndpoints[*].NetworkInterfaceIds' --output text)

# Get details for each network interface
for eni_id in $NETWORK_INTERFACE_IDS; do
  DETAILS=$(aws ec2 describe-network-interfaces --network-interface-ids "$eni_id" --query 'NetworkInterfaces[*].[PrivateIpAddress, Description, VpcId, SubnetId, Groups[*].GroupName, InterfaceType]' --output text)
  IP_ADDRESS=$(echo "$DETAILS" | awk '{print $1}')
  DESCRIPTION=$(echo "$DETAILS" | awk '{print $2}')
  VPC_ID=$(echo "$DETAILS" | awk '{print $3}')
  SUBNET_ID=$(echo "$DETAILS" | awk '{print $4}')
  SECURITY_GROUPS=$(echo "$DETAILS" | awk '{print $5}')
  INTERFACE_TYPE=$(echo "$DETAILS" | awk '{print $6}')

  echo "Network Interface ID: $eni_id"
  echo "IP Address: $IP_ADDRESS"
  echo "Description: $DESCRIPTION"
  echo "VPC ID: $VPC_ID"
  echo "Subnet ID: $SUBNET_ID"
  echo "Security Groups: $SECURITY_GROUPS"
  echo "Interface Type: $INTERFACE_TYPE"
  echo "-------------------------------------"
done
