LoginSignup
2
2

More than 3 years have passed since last update.

jqを使ってAWS CLIの出力を見やすくしよう

Posted at

例えばAWS CLIで RDSインスタンスの一覧を取得したい場合、、、

C:\Users\hoge>aws rds describe-db-instances
!!!!!JSONでずらずらと出力される!!!!!

見づらいので、jqを使って必要な出力に絞ります。
例)RDS一覧から、DBInstanceIdentifierのみ出力

C:\Users\hoge>aws rds describe-db-instances | jq '.DBInstances[].DBInstanceIdentifier'
jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Windows cmd shell quoting issues?) at <top-level>, line 1:
'.DBInstances[].DBInstanceIdentifier'
jq: 1 compile error

エラーになる。。。

Windowsだとシングルクオートではなくダブルクオートのようです。

C:\Users\hoge>aws rds describe-db-instances | jq ".DBInstances[].DBInstanceIdentifier"
"hoge-rds-01"
"hoge-rds-02"
"hoge-rds-03"
"hoge-rds-04"

また、-rオプションでダブルクオート抜きの出力となります。

C:\Users\hoge>aws rds describe-db-instances | jq -r ".DBInstances[].DBInstanceIdentifier"
hoge-rds-01
hoge-rds-02
hoge-rds-03
hoge-rds-04

[メモ]Postgresql RDSのログをきれいにみる方法

aws rds download-db-log-file-portion --db-instance-identifier hoge-postgresql --log-file-name error/postgres.log | jq -r ".LogFileData"
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2