Last active
March 11, 2020 16:19
-
-
Save LuRsT/b24513424edc118a8c35eab8044120b8 to your computer and use it in GitHub Desktop.
Connector - as seen on https://github.com/LuRsT/Setup/blob/master/bin/connector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/fish | |
# This is a script to connect into an EC2 instance from the cluster -> task definition -> instance | |
# Requirements: | |
# - fzf | |
# - jq | |
set CLUSTER (aws ecs list-clusters | jq '.clusterArns[]' | fzf --height 40% --reverse --header CLUSTER | awk -F/ '{print $2}' | sed 's/"//') | |
set service (aws ecs list-services --cluster $CLUSTER | jq '.serviceArns[]' | fzf --height 40% --reverse --header SERVICE | awk -F/ '{print $2}' | sed 's/"//') | |
set task (aws ecs list-tasks --cluster $CLUSTER --desired-status "RUNNING" --service $service | jq '.taskArns[]' | awk -F/ '{print $2}' | sed 's/"//') | |
set instance (aws ecs describe-tasks --cluster $CLUSTER --tasks $task | jq '.tasks[0].containerInstanceArn' | awk -F/ '{print $2}' | sed 's/"//') | |
set instance_id (aws ecs describe-container-instances --cluster $CLUSTER --container-instances $instance | jq '.containerInstances[0].ec2InstanceId' | sed 's/"//g') | |
set ip (aws ec2 describe-instances --instance-ids $instance_id | jq '.Reservations[0].Instances[0].PrivateDnsName' | sed 's/"//g') | |
ssh $ip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a script to connect into an EC2 instance from the cluster -> task definition -> instance | |
# Requirements: | |
# - fzf | |
# - jq | |
CLUSTER=$(aws ecs list-clusters | jq '.clusterArns[]' | fzf --height 40% --reverse --header CLUSTER | awk -F/ '{print $2}' | sed 's/"//') | |
service=$(aws ecs list-services --cluster $CLUSTER | jq '.serviceArns[]' | fzf --height 40% --reverse --header SERVICE | awk -F/ '{print $2}' | sed 's/"//') | |
task=$(aws ecs list-tasks --cluster $CLUSTER --desired-status "RUNNING" --service $service | jq '.taskArns[]' | awk -F/ '{print $2}' | sed 's/"//') | |
instance=$(aws ecs describe-tasks --cluster $CLUSTER --tasks $task | jq '.tasks[0].containerInstanceArn' | awk -F/ '{print $2}' | sed 's/"//') | |
instance_id=$(aws ecs describe-container-instances --cluster $CLUSTER --container-instances $instance | jq '.containerInstances[0].ec2InstanceId' | sed 's/"//g') | |
ip=$(aws ec2 describe-instances --instance-ids $instance_id | jq '.Reservations[0].Instances[0].PrivateDnsName' | sed 's/"//g') | |
ssh $ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment