From e4cdfe3fcdca9db87338bb814c38d8f88ec62e4a Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Wed, 6 Oct 2021 12:54:15 +0600 Subject: [PATCH] update ncd --- ncd | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ncd b/ncd index 82979e6..b79e0ab 100755 --- a/ncd +++ b/ncd @@ -36,16 +36,7 @@ ncd_config() { } ncd_ec2_ip() { - local -r ec2_name="${1}" - local -r filter="Name=tag:Name,Values=*${ec2_name}*" - local -r query='Reservations[*].Instances[*].{Id:InstanceId,Ip:PrivateIpAddress,Name:Tags[?Key==`Name`]|[0].Value}' - local -r items="$(aws ec2 describe-instances --filters "${filter}" --output json --query "${query}" | jq 'flatten')" - local -r selected_name=$(echo "${items}" | jq -r 'map(.Name) | .[]' | fzf --header "Select EC2 Name") - local -r selected_ip=$(echo "${items}" | jq -r --arg name "${selected_name}" 'map(select(.Name == $name))[0].Ip' ) - if [[ "${selected_ip}" = "null" ]]; then - exit 1 - fi - echo "${selected_ip}" + exec aws-ec2-ip $@ } ncd() { -- knotmirror 0.0.1