dotfiles/zsh/.local/share/zsh/functions/aws-ssm-connect
2025-10-20 19:44:10 +00:00

15 lines
564 B
Plaintext

aws-ssm-connect() {
local instance_id
instance_id=$(aws ec2 describe-instances \
--filters "Name=instance-state-name,Values=running" \
--query 'Reservations[].Instances[].[InstanceId,Tags[?Key==`Name`].Value|[0],PrivateIpAddress,InstanceType]' \
--output text \
| awk '{printf "%-20s %-40s %-15s %s\n", $1, $2, $3, $4}' \
| fzf --header="Instance ID Name IP Type" \
| awk '{print $1}')
[[ -z "$instance_id" ]] && return 1
aws ssm start-session --target "$instance_id"
}