问题
We have several EC2 instances that are in a private subnet, but gets a public IP address every time that instance is launched.
That private subnet has "Auto-assign Public IP" property set to No, but what happens is when instance was created, it got AssociatePublicIpAddress property set to true.
Now we don't know how to reset AssociatePublicIpAddress to false without terminating the instances.
I'd expect aws ec2 create-network-interface
would have an option for that, but it's not the case.
EC2 C# API has a method to change that - see here, but we don't use that API. EC2 Console UI is clearly missing that, and we can't find anything in aws cli too. Any ideas how to modify AssociatePublicIpAddress to false for an existing instace?
回答1:
Unfortunately you cannot dissociate a public IP from an EC2 instance:
You cannot manually associate or disassociate a public IP address from your instance
We release the public IP address for your instance when it's stopped or terminated
You will have to terminate the instance in order to remove the public IP address.
Source
来源:https://stackoverflow.com/questions/41727460/how-to-override-associatepublicipaddress-for-an-ec2-instance