Created
May 19, 2016 09:20
-
-
Save mungi/13e111c67e5bc1613a139b8cc1eb6d8b to your computer and use it in GitHub Desktop.
특정 ELB (여기선 myELB)에 소속되어 있는 running 중인 인스턴스의 사설 IP를 반환 해주는 CLI 입니다.
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 | |
ELB_NAME=myELB | |
IIDs=$(aws elb describe-instance-health --load-balancer-name $ELB_NAME --output text | awk '{print $3}') | |
aws ec2 describe-instances --instance-ids $IIDs --filters "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[*].PrivateIpAddress" --output=text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
리전명이 환경변수나 aws configure에 안잡혀 있으면 하기 옵션을 추가 해주셔야 합니다.
또는 하기처럼 환경변수셋팅을 먼저 해주셔도 됩니다.
export AWS_DEFAULT_REGION=ap-northeast-2