Tipsだけど忘れないように。
抽出したい条件に合わせて --arg TKey "Stack"
と --arg TValue "Production"
を変えて実行します。
例えば以下のような条件の場合、
Key | Value |
---|---|
Stack | Production |
こんな感じのワンライナーになります。
aws ec2 describe-instances | jq -r --arg TKey "Stack" --arg TValue "Production" '.Reservations[] | .Instances[] | select((.Tags[] | select(.Key == $TKey) | .Value) == $TValue) | "\(.Tags[] | select(.Key == "Name") | .Value),\(.InstanceId)"'
instanceA,i-d565e5f instanceB,i-5df4e6d2 ・・・