From 5a48a2e93e7afed8fa5dea8dd9135edd6687a7b2 Mon Sep 17 00:00:00 2001 From: Rob Date: Wed, 13 Apr 2016 07:21:58 +1000 Subject: [PATCH] Fix to ensure youngest snapshot is retrieved rather than oldest (#3115) --- lib/ansible/modules/cloud/amazon/ec2_snapshot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_snapshot.py b/lib/ansible/modules/cloud/amazon/ec2_snapshot.py index 26d874fca6f..7f0bfcee3c8 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_snapshot.py +++ b/lib/ansible/modules/cloud/amazon/ec2_snapshot.py @@ -148,7 +148,7 @@ def _get_most_recent_snapshot(snapshots, max_snapshot_age_secs=None, now=None): if not now: now = datetime.datetime.utcnow() - youngest_snapshot = min(snapshots, key=_get_snapshot_starttime) + youngest_snapshot = max(snapshots, key=_get_snapshot_starttime) # See if the snapshot is younger that the given max age snapshot_start = datetime.datetime.strptime(youngest_snapshot.start_time, '%Y-%m-%dT%H:%M:%S.000Z')