Issue
I'm trying to make simple script which queries my ec2 instances and gets public dns name of instances which matches my filter. There is my first shot:
#!/bin/bash
aws ec2 describe-instances \
--filters "Name=tag:app,Values=swarm-cluster" \
"Name=tag:role,Values=manager" \
--query "Reservations[*].Instances[*].PublicDnsName"
It almost works but I get something ugly:
[
[
""
],
[
"ec2-xxx-xxx-xxx-xxx.venus-central-1.compute.amazonaws.com"
]
]
I want just list of FQDNs, one per line. How to format output? I know, I can do it with tr, sed and so on but I'd like use more sophisticated way. :)
Solution
You can just append --output text
to your CLI call to get a text output.
Ref - https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output.html
Answered By - Michael Quale Answer Checked By - Mary Flores (WPSolving Volunteer)