Bugs That Bite
Published in

Bugs That Bite

unexpected EOF while looking for matching `”’

Trying to use jq to parse the output from aws ssm get-parameter

Ok so first of all, I do things in weird ways you shouldn’t do. That’s what makes me a hacker, I guess. I just do whatever works to get things done quickly and read the docs later.

In this case I wrote two quick functions to get an SSM parameter and parse the output to get the value of a parameter. However, I should really be using the AWS cli query and filter functions to do this. Save yourself some pain.

But anyway if you got this error here’s one thing that causes it.

My functions:

function get_ssm_param(){ echo $(aws ssm get-parameter --name $1 --with-decryption --profile $profile); }function get_ssm_param_value(){ echo $(jq -r .Parameter.Value <<< $1); }

They usually work but in this case they didn’t.

I have a value like this:

"ssm_base_ami" : "ami.linux.arm64"

I retrieve the parameter (note my last post on a bug with double quotes in the value of k):

p=$(get_ssm_param $k)

Then I try to get the value of my ssm parameter named ami.linux.arm64:

ami=$(get_ssm_param_value $p)

That produces the error message in the title of this post, which doesn’t look good again because it may be exposing information it shouldn’t. But I’m just trying to build something so I’m not going further. I’m not sure if this is caused by the periods in my parameter name or what and don’t have time to reverse engineer all that but the fix is to put quotes around my variable like this:

ami=$(get_ssm_param_value "$p")

Then it returns the correct value.

What is also odd, and I’m not going to dig into the internals and source of all of this but just show you the error so you can get your code working, is that I got a similar error after I fixed that one. Further down in my code I generate an ami name like this and a recent edit produced a typo. Do you see it?


Should be this:


The resulting error message from the above code provided a line of code much father down in the file because the parser kept parsing all the code due to the missing end apostrophe. I’m not even going to think about the implications of that right now.


Teri Radichel

If you liked this story please clap and follow:

Medium: Teri Radichel or Email List: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests services via LinkedIn: Teri Radichel or IANS Research

© 2nd Sight Lab 2022


About this blog:

Want to learn more about Cybersecurity and Cloud Security? Check out: Cybersecurity for Executives in the Age of Cloud on Amazon

Need Cloud Security Training? 2nd Sight Lab Cloud Security Training

Is your cloud secure? Hire 2nd Sight Lab for a penetration test or security assessment.

Have a Cybersecurity or Cloud Security Question? Ask Teri Radichel by scheduling a call with IANS Research.

Cybersecurity & Cloud Security Resources by Teri Radichel: Cybersecurity and Cloud security classes, articles, white papers, presentations, and podcasts



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store