diff options
-rw-r--r-- | cloud/amazon/ec2_vpc.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/cloud/amazon/ec2_vpc.py b/cloud/amazon/ec2_vpc.py index a4f7c0ad..af11a965 100644 --- a/cloud/amazon/ec2_vpc.py +++ b/cloud/amazon/ec2_vpc.py @@ -506,14 +506,15 @@ def create_vpc(module, vpc_conn): 'id': sn.id, }) - # Sort subnets by the order they were listed in the play - order = {} - for idx, val in enumerate(subnets): - order[val['cidr']] = idx - - # Number of subnets in the play - subnets_in_play = len(subnets) - returned_subnets.sort(key=lambda x: order.get(x['cidr'], subnets_in_play)) + if subnets is not None: + # Sort subnets by the order they were listed in the play + order = {} + for idx, val in enumerate(subnets): + order[val['cidr']] = idx + + # Number of subnets in the play + subnets_in_play = len(subnets) + returned_subnets.sort(key=lambda x: order.get(x['cidr'], subnets_in_play)) return (vpc_dict, created_vpc_id, returned_subnets, changed) |