일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 행정구역분류
- ffmpeg
- Flutter
- golang
- docker
- Kubernetes
- Java
- Android
- wireshark
- nginx-media-server
- android studio
- VSCode
- deployment
- dart
- Shell script
- RTMP
- service
- aws cli
- Python
- ebpf
- Pod
- kubectl
- macos
- Sysinternals
- configmap
- aws
- Windows10
- namespace
- spring cloud config
- HLS
Archives
- Today
- Total
woonizzooni
aws cli 명령 출력 제어 - Autoscaling 조회 using dictionary notation, 필터링... 본문
AWS
aws cli 명령 출력 제어 - Autoscaling 조회 using dictionary notation, 필터링...
woonizzooni 2020. 11. 9. 18:45
aws 명령의 default output format은 json임.
aws명령으로 이용하려는 서비스별 조회/생성/조회/업데이트/삭제 등의 동작을 할 수 있는데,
이중 'describe'명령 결과를 내 기호에 맞는 데이터와 형식으로 출력시켜보자.
o 기본 출력 예 (json)
$ aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names 이름-***
{
"AutoScalingGroups": [
{
"AutoScalingGroupName": "이름-***...",
"AutoScalingGroupARN": "arn:aws::........",
...
"MinSize": 2,
"MaxSize": 6,
"DesiredCapacity": 2,
"DefaultCooldown": 300,
"AvailabilityZones": [
"ap-northeast-2a",
"ap-northeast-2c"
],
"Instances": [
{
"InstanceId": "i-111111",
"InstanceType": "g4dn.xlarge",
"AvailabilityZone": "ap-northeast-2c",
"LifecycleState": "InService",
"HealthStatus": "Healthy",
"LaunchTemplate": {
...
},
"ProtectedFromScaleIn": true
...
},
{
"InstanceId": "i-222222",
"InstanceType": "g4dn.xlarge",
"AvailabilityZone": "ap-northeast-2c",
"LifecycleState": "InService",
"HealthStatus": "Healthy",
"LaunchTemplate": {
...
},
"ProtectedFromScaleIn": true
...
},
...
],
...
"CreatedTime": "2020-11-04T05:59:25.738Z",
...
o 기본 출력에서 'jq'로 원하는 데이터만 출력
$ aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names 이름-*** \
jq '.AutoScalingGroups[0].Instances'
[
{
"InstanceId": "i-111111",
"InstanceType": "g4dn.xlarge",
"AvailabilityZone": "ap-northeast-2c",
"LifecycleState": "InService",
"HealthStatus": "Healthy",
"LaunchTemplate": {
...
},
"ProtectedFromScaleIn": true
},
{
"InstanceId": "i-222222",
"InstanceType": "g4dn.xlarge",
"AvailabilityZone": "ap-northeast-2c",
"LifecycleState": "InService",
"HealthStatus": "Healthy",
"LaunchTemplate": {
...
},
"ProtectedFromScaleIn": true
}
]
o table 출력으로 변경
$ aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names 이름-*** --output table
------------------------------------------------------------
| DescribeAutoScalingGroups |
+----------------------------------------------------------+
|| AutoScalingGroup s ||
|+---------------------------+----------------------------+|
|| AutoScalingGroupARN | arn:aws::........ ||
|| AutoScalingGroupName | 이름-***... ||
|| CreatedTime | YYYY-mm-ddTHH:MM:SS.sssZ ||
|| DefaultCooldown | 300 ||
|| DesiredCapacity | 2 ||
|| MaxSize | 6 ||
|| MinSize | 2 ||
...
|+---------------------------+----------------------------+|
||| AvailabilityZones |||
||+------------------------------------------------------+||
||| ap-northeast-2a |||
||| ap-northeast-2c |||
||+------------------------------------------------------+||
||| Instances |||
||+--------------------------+---------------------------+||
||| AvailabilityZone | ap-northeast-2c |||
||| HealthStatus | Healthy |||
||| InstanceId | i-111111 |||
||| InstanceType | g4dn.xlarge |||
||| LifecycleState | InService |||
||| ProtectedFromScaleIn | True |||
||+--------------------------+---------------------------+||
|||| LaunchTemplate ||||
....
|||+----------------------------------------------------+|||
||| Instances |||
||+--------------------------+---------------------------+||
||| AvailabilityZone | ap-northeast-2c |||
||| HealthStatus | Healthy |||
||| InstanceId | i-222222 |||
||| InstanceType | g4dn.xlarge |||
||| LifecycleState | InService |||
||| ProtectedFromScaleIn | True |||
||+--------------------------+---------------------------+||
...
o table출력에서 원하는 데이터와 컬럼으로 필터링 / 재정의(?) (dictionary notation 활용)
$ aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names 이름-*** \
--output table \
--query 'AutoScalingGroups[*].Instances[*].{ID:InstanceId, STATUS:HealthStatus, PROTECTED:ProtectedFromScaleIn}';
----------------------------------------
| DescribeAutoScalingGroups |
+-------------+-------------+----------+
| ID | PROTECTED | STATUS |
+-------------+-------------+----------+
| i-111111 | True | Healthy |
| i-222222 | True | Healthy |
+-------------+-------------+----------+
[참고]
docs.aws.amazon.com/cli/latest/userguide/cli-usage-output.html
docs.aws.amazon.com/cli/latest/userguide/cli-usage-output.html#cli-usage-output-filter
'AWS' 카테고리의 다른 글
AWS CLI 버전1 구성 (windows 10) (0) | 2021.05.24 |
---|---|
Amazon SQS : the specified queue does not exist or you do not have access to it (0) | 2020.12.30 |
AWS SDK for Golang - Session 재사용 (0) | 2020.11.06 |
EKS 클러스터 인증 관리 (0) | 2020.03.30 |
AWS CLI 구성 (MacOS) (0) | 2020.03.29 |
Comments