mirror of
https://github.com/nmasur/dotfiles
synced 2024-09-20 11:44:46 +00:00
22 lines
820 B
Bash
22 lines
820 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
# Retrieve list of AWS instances
|
||
|
# Use enter to jump into their sessions with SSM
|
||
|
|
||
|
# Specify AWS_PROFILE and AWS_REGION before running this script
|
||
|
|
||
|
aws ec2 describe-instances |
|
||
|
jq -r \
|
||
|
'.Reservations[]
|
||
|
| .Instances[]
|
||
|
| .InstanceId + " - " +
|
||
|
(.PrivateIpAddress // "n/a") + " - " +
|
||
|
(.PublicIpAddress // "n/a") + " - " +
|
||
|
(.Tags | from_entries | .Name // "n/a")' |
|
||
|
fzf \
|
||
|
--height 100% \
|
||
|
--layout reverse \
|
||
|
--header $'Press Enter to start SSM session\nInstance ID - Private IP - Public IP - Name' \
|
||
|
--preview "aws ec2 describe-instances --instance-ids \"\$(echo {} | cut -d' ' -f1)\" | jq -r '.Reservations[].Instances[0]'" \
|
||
|
--bind "enter:become(aws ssm start-session --target \$(echo {} | cut -d' ' -f1))"
|