‘int’ object is not iterable: CloudFormation
The mysterious error that doesn’t really explain what’s going on with parameter-overrides
I got the above error while trying to execute a CloudFormation template. Actually I got it a couple of times and by the second time I got it I already forgot what caused it.
Wasted time. Wasted time…please better error messages…
What happened the first time is that I was constructing a string for my parameter overrides in a CLI call and inadvertently passed in an empty string, so the parameter overrides were malformed.
How about an error that says exactly that:
The parameter overrides value malformed. It should be in this form ["x=y","z=q","b=d”]
The template actually executed so I though the error was in my template code and wasted time on that. I always print out my parameters due to a myriad of cryptic error messages related to parameter overrides so I can verify they are correct, so I finally spotted what I was doing wrong.
By the way there are multiple ways to pass in parameter overrides and I’ve had best luck with the above format — especially when there are spaces in one of the parameter values.
The second time I got this error I actually thought I was done with my code. Somehow I inadvertently replaced all my parameters with the number 1. Don’t ask me how. But once again I got this nonsensical error:
‘int’ object is not iterable
This time the error was only on the command line. The template never executed. Just this:
So how was I supposed to know this was not an error in my template code but with the CLI call? A little hint would be nice.
Now that I’ve written this down in a blog post hopefully I will remember what the problem is next time I see it.
Update:
Even more bizarre…is that when I finished writing this post and went back and printed out my parameters to see what is going on and without making any other changes the code worked again. I don’t know how parameter-overrides got set to 1 or how it got fixed. Multi-threaded coding error? Not sure. Will have to see if it happens again.
Update 9/22/2022 6:17 PM ET:
I’m tracking this bug as it is random and not sure what causes it. It seems to be happening when I look through some numbers to create subnets. Everything will run fine and did all morning. Then in the evening it starts failing. I don’t know if the morning / evening thing is consistent yet but it seems to be. I’ll track it moving forward and record when it happens.
I commented out the functions that deploy subnets and NACLs and the rest of the code works fine. The main difference with the code to deploy subnets is the iterator from 1 to n to deploy subnets. I am not writing any multi-threaded code so as far as I know there should be no confusion between threads unless that is happening on the underlying OS. Somehow these values calculate fine and suddenly the script starts failing and my parameters get set to “1”.
The only thing I have that could be setting values to 1 is this function which kicks out 1 as an error. This function is in a different file included with “source”:
However, if my values were not set properly by my own code, it seems like I would get the error consistently, but it comes and goes with no changes to this code.
Also, I randomly get a 1 in my current folder all the time after errors, even errors unrelated to this one:
I deleted that “1” above and re-ran my script. See, now suddenly it works again:
I don’t know if deleting that 1 had anything to do with it. No code changes.
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
____________________________________________
Author:
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