Skip to content

Instantly share code, notes, and snippets.

@lbjay
Created July 11, 2019 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbjay/c34785cbaf6df3c9ecdf3f3d9c1bde9c to your computer and use it in GitHub Desktop.
Save lbjay/c34785cbaf6df3c9ecdf3f3d9c1bde9c to your computer and use it in GitHub Desktop.
oc ssh andele andele
function oc-ips {
aws_profile=${1:-test}
cluster_name=$(sed -n 's/cluster=cluster_config-\([^\.]\+\)\.json/\1/p' .ocopsworks.rc)
aws --profile $aws_profile ec2 describe-instances \
--output text \
--filters "Name=tag:opsworks:stack,Values=$cluster_name" \
--query "Reservations[].Instances[].[Tags[?Key=='opsworks:instance']|[0].Value,PublicIpAddress]" \
> .oc-ips
}
function ssh_to {
hostname=$1
ip=$(grep "^$hostname" .oc-ips | cut -f 2)
ssh -A -t $ip
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment