spulec/moto — pull request #196 by DreadPirateShawn (2014-09-10 16:53:08+00:00)
Title: Security Groups: Fix for filtering support.

This fixes #195.

There were two nested problems:
* The "to_attr" conversion checked "attr" (always None) instead of the passed "filter_name" param
* The foreach/else loop had a break on "if not ret" instead of "if ret" (proper) -- the "break" action is what causes the "else" clause to be skipped. So "if not ret: break" meant that a True match would not break, thus entering the else clause, and the True match would result in a False verdict.

My fix was a minor refactor which no longer uses a foreach/else loop -- between my having to look up the semantics to make sure I wasn't crazy, and the logic having a bug in the first place, I think it's a bit more complex than we need here.

Bonus: I also added a couple of lines for the "vpc-id" filter while I was in there.