CloudWiki

Amazon Web Service (AWS)

Elastic IP

Network
An Elastic IP (EIP) is a public and static IPv4 address that is reachable from the internet and replaces the default public IP address of your EC2 instance. An Elastic IP address is allocated to your AWS account, and it’s yours until you release it. Its main purpose is to mask a failure of your EC2 instance or application by remapping the IP address to another instance within your account.
aws_eip
Elastic IP
attributes:
  • address - (Optional) IP address from an EC2 BYOIP pool. This option is only available for VPC EIPs.
  • associate_with_private_ip - (Optional) User-specified primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
  • customer_owned_ipv4_pool - (Optional) ID of a customer-owned address pool. For more on customer owned IP addressed check out Customer-owned IP addresses guide.
  • instance - (Optional) EC2 instance ID.
  • network_border_group - (Optional) Location from which the IP address is advertised. Use this parameter to limit the address to this location.
  • network_interface - (Optional) Network interface ID to associate with.
  • public_ipv4_pool - (Optional) EC2 IPv4 address pool identifier or amazon. This option is only available for VPC EIPs.
  • tags - (Optional) Map of tags to assign to the resource. Tags can only be applied to EIPs in a VPC. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
  • vpc - (Optional) Boolean if the EIP is in a VPC or not. Defaults to true unless the region supports EC2-Classic.

Associating resources with a
Elastic IP
Resources do not "belong" to a
Elastic IP
Rather, one or more Security Groups are associated to a resource.
Create
Elastic IP
via Terraform:
The following HCL associates an instance with a single Elastic IP
Syntax:

resource "aws_eip" "lb" {
 instance = aws_instance.web.id
 vpc      = true
}

Create
Elastic IP
via CLI:
Parametres:

allocate-address
[--domain <value>]
[--address <value>]
[--public-ipv4-pool <value>]
[--network-border-group <value>]
[--customer-owned-ipv4-pool <value>]
[--dry-run | --no-dry-run]
[--tag-specifications <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]

Example:
Best Practices for
Elastic IP

Categorized by Availability, Security & Compliance and Cost

Warning
Elastic IP not in use
Explore all the rules our platform covers
All Resources