diff --git a/lib/ansible/modules/cloud/amazon/ec2_metadata_facts.py b/lib/ansible/modules/cloud/amazon/ec2_metadata_facts.py index e0ebc68802..3d8b178648 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_metadata_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_metadata_facts.py @@ -532,7 +532,8 @@ class Ec2Metadata(object): data = self.fix_invalid_varnames(data) # Maintain old key for backwards compatibility - data['ansible_ec2_placement_region'] = data['ansible_ec2_instance_identity_document_region'] + if 'ansible_ec2_instance_identity_document_region' in data: + data['ansible_ec2_placement_region'] = data['ansible_ec2_instance_identity_document_region'] return data