toy
toy

Reputation: 12151

How do I get the output of jq to pipe to curl

I'm trying to query AWS EC2 ip addresses and use that addresses to curl the version of the box. The query path I could do it but I'm not sure how to get the output of jq to curl

Here's the command I use

aws ec2 describe-instances \
        --filters "Name=tag:App,Values=app01" \
        --query "Reservations[*].Instances[*].PrivateIpAddress" | jq 'flatten'

And this is the results I got

[
  "10.xx.xx.xxx",
  "10.xx.xx.xxx",
]

What I would like it to be is

curl http://10.xx.xx.xxx:8081/version

Upvotes: 0

Views: 1496

Answers (1)

Cyrus
Cyrus

Reputation: 88756

Append:

| grep -Eo '[0-9.]{7,14}' | xargs -I {} echo curl http://{}:8081/version

If everything looks okay, remove echo.

Upvotes: 1

Related Questions