Skip to content

Commit

Permalink
Fix ec2_group for EC2-Classic accounts (ansible#46242)
Browse files Browse the repository at this point in the history
* Fix ec2_group for EC2-Classic accounts

* changelog
  • Loading branch information
s-hertel authored Sep 28, 2018
1 parent 23c9429 commit 9efc3dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bugfixes:
- The patch fixing the regression of no longer preferring matching security
groups in the same VPC https://github.com/ansible/ansible/pull/45787
(which was also backported to 2.6) broke EC2-Classic accounts.
https://github.com/ansible/ansible/pull/46242 removes the assumption that
security groups must be in a VPC.
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/amazon/ec2_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9efc3dc

Please sign in to comment.