The problem with AWS auto-assignment of public IPv4 addresses to EC2 instances is that the IP address is released once the EC2 instance is stopped, and a new public IPv4 address is assigned to it when it is started again. This can be problematic in cases where persistent network communication is required between resources, and it can result in a lot of manual overhead. The above problem is solved by providing access to a static public IPv4 address that does not change and can be reused as needed.

An Elastic IP (EIP) is a static public IPv4 address allocated from a pool of public IPv4 addresses that can be associated with an EC2 instance or a network interface in AWS. Elastic IPs are regional; by default, each AWS account is limited to allocating up to five Elastic IP addresses per region.

Note: For the Elastic IPs that are not in use, AWS charges an hourly fee. For example, if it’s not associated with any resources, associated to a stopped EC2 instance, or associated to an unused network interface.

Elastic IP operations

Allocate an Elastic IP

An Elastic IP must be allocated to an AWS account before it can be used. An Elastic IP can be chosen from one of the following:

  1. Amazon’s pool of IP addresses

  2. Self-brought IP addresses using bring your own IP addresses (BYOIP)

  3. The customer-owned pool of IP addresses

The following command can be used to allocate an Elastic IP from Amazon’s pool of IP addresses:

Get hands-on with 1200+ tech skills courses.