diff --git a/lib/ansible/modules/cloud/amazon/ec2_ami_facts.py b/lib/ansible/modules/cloud/amazon/ec2_ami_facts.py index 296a893aa16..fe8b57e7640 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_ami_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_ami_facts.py @@ -234,6 +234,7 @@ def list_ec2_images(ec2_client, module): # describing launch permissions of images owned by others is not permitted, but shouldn't cause failures pass + images.sort(key=lambda e: e.get('creation_date', '')) # it may be possible that creation_date does not always exist module.exit_json(images=images)