퍼블릭 클라우드
[aws] AWS CLI를 사용하여 실행 중인 인스턴스를 조회하는 쉘 스크립트
변군이글루
2023. 3. 17. 16:41
반응형
AWS CLI를 사용하여 실행 중인 인스턴스를 조회하는 쉘 스크립트
instance-search.sh 스크립트 생성
vim instance-search.sh
#!/bin/bash
# Describe running EC2 instances
aws ec2 describe-instances \
--filters "Name=instance-state-name,Values=running" \
--query 'Reservations[*].Instances[*].{
Name: Tags[?Key==`Name`]|[0].Value,
InstanceId: InstanceId,
InstanceType: InstanceType,
PrivateIpAddress: PrivateIpAddress,
PublicIpAddress: PublicIpAddress,
State: State.Name,
LaunchTime: LaunchTime
}' \
--output table
chmod +x instance-search.sh
인스턴스 목록 출력
- Name: 인스턴스 이름
- InstanceId: 인스턴스 ID
- InstanceType: 인스턴스 유형
- PrivateIpAddress: 프라이빗 IP 주소
- PublicIpAddress: 퍼블릭 IP 주소
- State: 인스턴스 상태
- LaunchTime: 인스턴스 시작 시간
참고URL
- Shell 스크립트로 Amazon Machine Image(AMI) 생성하기 : https://scbyun.com/1178
728x90
반응형