Skip to content

private-ip-details: displays basic information about where a private IP is attached to and what owns it. #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aliases
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ alias launch-configuration-asgs='~/.bash-my-aws/bin/bma launch-configuration-asg
alias launch-configurations='~/.bash-my-aws/bin/bma launch-configurations'
alias log-groups='~/.bash-my-aws/bin/bma log-groups'
alias pcxs='~/.bash-my-aws/bin/bma pcxs'
alias private-ip-details='~/.bash-my-aws/bin/bma private-ip-details'
alias rds-db-clusters='~/.bash-my-aws/bin/bma rds-db-clusters'
alias rds-db-instances='~/.bash-my-aws/bin/bma rds-db-instances'
alias region-each='~/.bash-my-aws/bin/bma region-each'
Expand Down Expand Up @@ -167,4 +168,4 @@ function region() {
else
AWS_DEFAULT_REGION="$inputs";
fi
}
}
35 changes: 35 additions & 0 deletions lib/ec2-functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# ec2-functions
#
# Generic EC2 functions


private-ip-details() {
# Outputs information about a list of IPs
#
# $ private-ip-details 10.1.2.3 10.2.3.4 10.3.4.5
# None None 10.1.2.3 vpc_endpoint 111111111111 eni-aaaaaaaaaaaaaaaaa in-use
# None None 10.2.3.4 interface amazon-elb eni-bbbbbbbbbbbbbbbbb in-use
# i-123456 1.2.3.4 10.3.4.5 interface None eni-ccccccccccccccccc in-use


local ips=$(skim-stdin "$@")
local joined_ips=$(echo $ips | sed "s/ /,/g")

aws ec2 describe-network-interfaces \
--filters "Name=addresses.private-ip-address,Values=$joined_ips" \
--query \
"NetworkInterfaces[][
Attachment.InstanceId,
Association.PublicIp,
PrivateIpAddress,
InterfaceType,
RequesterId,
NetworkInterfaceId,
Status
]" \
--output text |
column -s $'\t' -t

}