Skip to content

Instantly share code, notes, and snippets.

@mungi
Created May 19, 2016 09:20
Show Gist options
  • Save mungi/13e111c67e5bc1613a139b8cc1eb6d8b to your computer and use it in GitHub Desktop.
Save mungi/13e111c67e5bc1613a139b8cc1eb6d8b to your computer and use it in GitHub Desktop.
특정 ELB (여기선 myELB)에 소속되어 있는 running 중인 인스턴스의 사설 IP를 반환 해주는 CLI 입니다.
#!/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
@mungi
Copy link
Author

mungi commented May 19, 2016

리전명이 환경변수나 aws configure에 안잡혀 있으면 하기 옵션을 추가 해주셔야 합니다.

--region ap-northeast-2

또는 하기처럼 환경변수셋팅을 먼저 해주셔도 됩니다.

export AWS_DEFAULT_REGION=ap-northeast-2

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