diff --git a/moto/ec2/models.py b/moto/ec2/models.py index e3342c8c8..418cac3fa 100755 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -549,6 +549,10 @@ class Instance(BotoInstance, TaggedEC2Resource): self.attach_eni(use_nic, device_index) + def set_ip(self, ip_address): + # Should we be creating a new ENI? + self.nics[0].public_ip = ip_address + def attach_eni(self, eni, device_index): device_index = int(device_index) self.nics[device_index] = eni @@ -2663,6 +2667,7 @@ class ElasticAddressBackend(object): eip.eni.public_ip = eip.public_ip if eip.domain == "vpc": eip.association_id = random_eip_association_id() + instance.set_ip(eip.public_ip) return eip diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py index 9670d64f9..2fed60119 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -207,6 +207,7 @@ EC2_RUN_INSTANCES = """