[cloud] Ensure absence of public_dns_name doesn't halt ec2 module (#31476)

This commit is contained in:
Ryan Fitzpatrick 2017-10-09 17:04:25 -04:00 committed by Ryan Brown
parent 75c5d0fedc
commit 2ba5998c94

View file

@ -1618,7 +1618,8 @@ def warn_if_public_ip_assignment_changed(module, instance):
assign_public_ip = module.params.get('assign_public_ip')
# Check that public ip assignment is the same and warn if not
if (assign_public_ip or instance.public_dns_name) and (not instance.public_dns_name or not assign_public_ip):
public_dns_name = getattr(instance, 'public_dns_name', None)
if (assign_public_ip or public_dns_name) and (not public_dns_name or not assign_public_ip):
module.warn("Unable to modify public ip assignment to {0} for instance {1}. "
"Whether or not to assign a public IP is determined during instance creation.".format(assign_public_ip, instance.id))