PutKeyPolicy failed due to MalformedPolicyDocumentException
A single letter in a misspelled condition…
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Check out my series on Automating Cybersecurity Metrics. The Code.
🔒 Related Stories: AWS Security | Application Security | CloudFormation
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sometimes the errors you get back really could be a bit more helpful. I don’t know if this error message is coming from KMS or CloudFormation but based on my experiences to date with KMS I am guessing that CloudFormation calls a KMS API and prints out exactly what the KMS service returns.
PutKeyPolicy failed due to MalformedPolicyDocumentExceptionNow when you have a very long and complex key policy, it would be super nice if whatever is parsing this key policy could be a bit more specific. Don’t just pass back whatever the Yaml or JSON parse spits out but try to figure out what exactly is the error? At a minimum, indicate what line caused the error.
This is one of those issues where I stared and stared at the code and couldn’t see it. Well, I’m not kidding when I say I should probably wear glasses but it’s such a hassle to go get them. I increased the size of the font and then it was obvious. I had a typo in my condition statement.
I wrote:
stringEualswhen it should have been
stringEqualsRight before this I had another error which was caused by a misalignment of dashes in a list:
-
-
-
-There must be a way the policy parser could help a sista out and tell me what the problem is in the error message??
Anyway, I keep writing these down because I forget what causes them and then I can return to my blog to remind myself, but it seems like this could be a bit more automated with better error messages. If nothing else I need to write my own parser someday but I’m not getting paid by AWS to do that and I have other priorities at the moment. :)
Follow for updates.
Teri Radichel | © 2nd Sight Lab 2022
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight LabNeed Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for PresentationFollow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab



