creates security groups if they don't already exist

This creates security groups on ec2 if they don't already exist.
I misread that.  It isn't a method each of the elements, but a key in a hash, so you are right and it wouldn't work.  Carry on.