aws cli 使うの楽なんですけど、queryを構造見ながら組み立てるのメモっとく場所上手に探せないので、シェルにしてみた。
一部、変数のprivate_key_pathってのは自分の環境のプライベートキー置いとく場所に変えて使うやつがあります。
* elastic beans talk の環境名だけテキストに出す
sh eb-env-names.sh
* elastic beans talk の環境名を指定してautoscaling AutoScalingGroupsの名前とか出す。
sh eb-env.sh 環境名
* オートスケーリンググループの名前を指定してssh接続コピペで出来るように文字列出す。
sh as-instances-privateip.sh オートスケーリンググループ名
(ssh -i ~/.ssh/プライベートキー名 ec2-user@ホスト名って文字列にしてくれる。)
* 上のやつのpriavate ip版 awsの環境内でつなぐ時用
sh as-instances.sh オートスケーリンググループ名
* オートスケーリングのグループ名だけ出す。
as-names.sh
* elbの名前だけ出す。
elb-names.sh
* ELBの名前を指定してssh接続コピペで出来るように文字列出す。public用。
elb-instances.sh
* ELBの名前を指定してssh接続コピペで出来るように文字列出す。priavete ip 用。
elb-instances-privateip.sh
gistはこちら。
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/sh | |
asname=$1 | |
private_key_path="~/.ssh/your-private-key.pem" | |
instances=$(aws autoscaling describe-auto-scaling-instances –query "AutoScalingInstances[?AutoScalingGroupName==\`$asname\`][InstanceId]" –output text) | |
query_private_ip='Reservations[].[Instances[][NetworkInterfaces][][][PrivateIpAddresses][][][PrivateIpAddress]]' | |
dnslist=`aws ec2 describe-instances –instance-ids $instances –query "$query_private_ip" –output text` | |
for hostname in $dnslist | |
do | |
echo "ssh -i $private_key_path ec2-user@$hostname" | |
done | |
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/sh | |
asname=$1 | |
private_key_path="~/.ssh/your-private-key.pem" | |
instances=$(aws autoscaling describe-auto-scaling-instances –query "AutoScalingInstances[?AutoScalingGroupName==\`$asname\`][InstanceId]" –output text) | |
dnslist=`aws ec2 describe-instances –instance-ids $instances –query 'Reservations[][Instances[][PublicDnsName]]' –output text` | |
for hostname in $dnslist | |
do | |
echo "ssh -i $private_key_path ec2-user@$hostname" | |
done | |
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/sh | |
aws autoscaling describe-auto-scaling-groups –query 'AutoScalingGroups[][AutoScalingGroupName]' –output text | |
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/sh | |
aws elasticbeanstalk describe-environments –query Environments[][EnvironmentName] –output text | |
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/sh | |
envname=$1 | |
aws elasticbeanstalk describe-environment-resources –environment-name $envname | |
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/sh | |
private_key_path="~/.ssh/your-private-key.pem" | |
lbname=$1 | |
instances=`aws elb describe-load-balancers –load-balancer-names $lbname –query 'LoadBalancerDescriptions[][Instances[][InstanceId]]' –output text` | |
query_private_ip='Reservations[].[Instances[][NetworkInterfaces][][][PrivateIpAddresses][][][PrivateIpAddress]]' | |
dnslist=`aws ec2 describe-instances –instance-ids $instances –query "$query_private_ip" –output text` | |
for hostname in $dnslist | |
do | |
echo "ssh -i ~/.ssh/aws-lockad.pem ec2-user@$hostname" | |
done |
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/sh | |
lbname=$1 | |
private_key_path="~/.ssh/your-private-key.pem" | |
instances=`aws elb describe-load-balancers –load-balancer-names $lbname –query 'LoadBalancerDescriptions[][Instances[][InstanceId]]' –output text` | |
dnslist=`aws ec2 describe-instances –instance-ids $instances –query 'Reservations[][Instances[][PublicDnsName]]' –output text` | |
for hostname in $dnslist | |
do | |
echo "ssh -i $private_key_path ec2-user@$hostname" | |
done |
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/sh | |
aws elb describe-load-balancers –query 'LoadBalancerDescriptions[][LoadBalancerName]' –output text |