@ -295,8 +295,13 @@ def main():
rule [ ' from_port ' ] = None
rule [ ' to_port ' ] = None
# Convert ip to list we can iterate over
if not isinstance ( ip , list ) :
ip = [ ip ]
# If rule already exists, don't later delete it
ruleId = make_rule_key ( ' in ' , rule , group_id , ip )
for thisip in ip :
ruleId = make_rule_key ( ' in ' , rule , group_id , thisip )
if ruleId in groupRules :
del groupRules [ ruleId ]
# Otherwise, add new rule
@ -306,7 +311,7 @@ def main():
grantGroup = groups [ group_id ]
if not module . check_mode :
group . authorize ( rule [ ' proto ' ] , rule [ ' from_port ' ] , rule [ ' to_port ' ] , ip, grantGroup )
group . authorize ( rule [ ' proto ' ] , rule [ ' from_port ' ] , rule [ ' to_port ' ] , this ip, grantGroup )
changed = True
# Finally, remove anything left in the groupRules -- these will be defunct rules
@ -335,8 +340,13 @@ def main():
rule [ ' from_port ' ] = None
rule [ ' to_port ' ] = None
# Convert ip to list we can iterate over
if not isinstance ( ip , list ) :
ip = [ ip ]
# If rule already exists, don't later delete it
ruleId = make_rule_key ( ' out ' , rule , group_id , ip )
for thisip in ip :
ruleId = make_rule_key ( ' out ' , rule , group_id , thisip )
if ruleId in groupRules :
del groupRules [ ruleId ]
# Otherwise, add new rule
@ -352,7 +362,7 @@ def main():
from_port = rule [ ' from_port ' ] ,
to_port = rule [ ' to_port ' ] ,
src_group_id = grantGroup ,
cidr_ip = ip)
cidr_ip = this ip)
changed = True
elif vpc_id and not module . check_mode :
# when using a vpc, but no egress rules are specified,