Skip to content

Instantly share code, notes, and snippets.

@maimai-swap
Created January 29, 2015 06:06
Show Gist options
  • Save maimai-swap/24cd61e5074bf1303e15 to your computer and use it in GitHub Desktop.
Save maimai-swap/24cd61e5074bf1303e15 to your computer and use it in GitHub Desktop.
elasticbeanstalk elb autoscaling 使うときのシェルとかqueryがめんどくさいのでメモ
#!/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
#!/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
#!/bin/sh
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[][AutoScalingGroupName]' --output text
#!/bin/sh
aws elasticbeanstalk describe-environments --query Environments[][EnvironmentName] --output text
#!/bin/sh
envname=$1
aws elasticbeanstalk describe-environment-resources --environment-name $envname
#!/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
#!/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
#!/bin/sh
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[][LoadBalancerName]' --output text
@maimai-swap
Copy link
Author

http://wp.me/p2Tl24-52 ブログはこちら

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment