I want to have a public IP address for my EC2 instance that will persist even if my instance is stopped and restarted. How do I do that?
An Elastic IP address is a reserved public IP address that you can assign to any EC2 instance in a particular region, until you choose to release it. To allocate an Elastic IP address to your account in a particular region, see Allocating an Elastic IP Address.
When you associate an Elastic IP address with an EC2 instance, it replaces the default public IP address. If an external hostname was allocated to the instance from your launch settings, it will also replace this hostname; otherwise, it will create one for the instance. The Elastic IP address remains in place through events that normally cause the address to change, such as stopping or restarting the instance.
Note: This description applies to most AWS accounts, which are EC2-VPC by default. If your account is EC2-Classic, see Elastic IP Address Differences for EC2-Classic and EC2-VPC.