From 96494c2177b963e1bdf08003554b5a1f1b1fb350 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Tue, 12 Jul 2022 11:43:33 +0200 Subject: [PATCH] ec2_vpc_peer - Fix idempotency when accepter/requester is reversed (#1346) ec2_vpc_peer - Fix idempotency when accepter/requester is reversed SUMMARY fixes: #580 Fixes a bug where a new peering request would be created when the accepter/requester is reversed ISSUE TYPE Bugfix Pull Request COMPONENT NAME plugins/modules/ec2_vpc_peer.py ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis --- ec2_vpc_peer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ec2_vpc_peer.py b/ec2_vpc_peer.py index 79bcbf58b59..2034f234340 100644 --- a/ec2_vpc_peer.py +++ b/ec2_vpc_peer.py @@ -394,6 +394,11 @@ def describe_peering_connections(params, client): Filters=ansible_dict_to_boto3_filter_list(peer_filter), ) if result['VpcPeeringConnections'] == []: + # Try again with the VPC/Peer relationship reversed + peer_filter = { + 'requester-vpc-info.vpc-id': params['PeerVpcId'], + 'accepter-vpc-info.vpc-id': params['VpcId'], + } result = client.describe_vpc_peering_connections( aws_retry=True, Filters=ansible_dict_to_boto3_filter_list(peer_filter),