티스토리 뷰

공부

[ec2] aws cli + jq

승가비 2023. 4. 7. 03:10
728x90
#!/bin/bash

GROUP=$1
PORT=$2

aws ec2 describe-instances \
  --filters "Name=instance-state-name,Values=running" | \
  jq -r --arg GROUP "${GROUP}" --arg PORT "${PORT}" \
  '.Reservations[].Instances[] | $GROUP + " / " + (.PlatformDetails | split("/") | join(" / "))+ " / " + (.Tags[] | select(.Key == "Name") | .Value) + " / " + .PrivateIpAddress + " / " + $PORT'

# group / Linux / UNIX / abc / 1.2.3.4 / port

 

https://gist.github.com/hummus/8592113

 

aws cli + jq example

aws cli + jq example. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

https://stackoverflow.com/questions/40027395/passing-bash-variable-to-jq

 

728x90
댓글