AWS CloudFormation Policy Document Error Messages Could Be Nicer
Telling me I have an invalid policy document with no further information is not helpful — and the errors in this post seem like they would be easy to pass through
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Part of 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I was just getting some errors with a policy document for a VPC Endpoint. The error messages are simply this:
InvalidPolicyDocument (Service: AmazonEC2; Status Code: 400; Error Code: InvalidPolicyDocument; Request ID: xxx; Proxy: null)Here are some obvious things that the error message could tell you:
- You are missing a principal when one is required. This should be easy to figure out by parsing the document for the word “Principal.”
- The principal is not valid if it is not an ARN when it’s supposed to be or if it is not matching an ID properly in the account. This also seems like it would be easy to parse out?
- The principal needs to start with “AWS” if it doesn’t.
- A colon or a dash is in the wrong place.
- The spacing or indentation is off.
- There’s a problem with a condition
I don’t know what the problem is with the stack at this point so I reverted to an example in the AWS Documentation as I presume that works and removed my specific principal and resources.
Next I changed one value at a time and redeployed my stack to see which one was causing the error.
After deploying one element of the policy at a time I realized that in addition to some of the above errors I had inadvertently added “Role” at the end of a Role name when I shouldn’t have. It seems like it should be obvious that the ARN is in the correct format, the account ID is correct, but the specific role name does not exist.
AWS, help a dev out and give a little more guidance about these errors in CloudFormation. You’ll save the world loads of time. #awswishlist
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
