Fix ec2_group for EC2-Classic accounts (#46242)

* Fix ec2_group for EC2-Classic accounts

* changelog
This commit is contained in:
Sloane Hertel 2018-09-27 23:11:04 -04:00 committed by GitHub
commit 9efc3dc761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -856,7 +856,7 @@ def group_exists(client, module, vpc_id, group_id, name):
groups = dict((group['GroupId'], group) for group in all_groups)
groups.update(dict((group['GroupName'], group) for group in all_groups))
if vpc_id:
vpc_wins = dict((group['GroupName'], group) for group in all_groups if group['VpcId'] == vpc_id)
vpc_wins = dict((group['GroupName'], group) for group in all_groups if group.get('VpcId') and group['VpcId'] == vpc_id)
groups.update(vpc_wins)
# maintain backwards compatibility by using the last matching group
return security_groups[-1], groups