1

Getting response back from AWS CLI call:

aws sns get-topic-attributes --query 'Attributes.Policy'

gives me the whole policy.

I would like to query specifically on one policy statement, by value of the Sid.

I Have tried:

  • --query "[Attributes.Policy [?Statement.Sid==`mySid`]"
  • --query "[Attributes.Policy.Statement [?Sid==`mySid`]"
  • --query="(Attributes.Policy.Statement[?Sid=='mySid'])"

and various other fruitless attempts.

Any help is appreciated.

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Danielle
  • 53
  • 4
  • 1
    Policy is a string (albeit with a JSON string inside it). Suspect that you can't interrogate it the way you want (by parsing the JSON string and then filtering on Sid). Maybe you could leverage `jq` after the fact. – jarmod Mar 28 '22 at 18:44
  • Does this answer your question? [JMESPath - parse raw string as object](https://stackoverflow.com/questions/49827825/jmespath-parse-raw-string-as-object) – β.εηοιτ.βε Mar 28 '22 at 18:46
  • Thanks for the tip, I will try that. I used 'sed' instead and it gave me a bit like what I wanted, but wouldn't mind something less janky. – Danielle Mar 28 '22 at 19:34

0 Answers0