Use an elastic IP
Hold a public IPv4 address independently of any machine, attach it to an instance, move it, and release it.
Replace the ids with your own. On your organization's own hosts an elastic IP works differently; see Instances on your own hosts.
Important
An elastic IP is metered every hour it is allocated, attached or not, until you release it, as an hourly share of its monthly price. Where elastic IPs are not charged yet, the console shows the cost as "metered, not charged yet"; you are told before charging starts.
Prerequisites
- In the console, also
ec2:DescribeInstancesto open the instance's page (without it the page is not found). - Permission for
ec2:AllocateAddress,ec2:AssociateAddress,ec2:DisassociateAddressandec2:ReleaseAddress, as the step needs. - In the console, also
ec2:DescribeAddressesto open Elastic IPs (without it the page says "Access denied"). - Room in the elastic IP quota.
- To attach the address in the console: an instance that is running or stopped, in the address's region.
Allocate an address
- Open Compute, then Elastic IPs, and choose Create Elastic IP.
- In Allocate Elastic IP, for Region, choose the region.
- Choose Allocate.
dcloud ec2 elastic-ips allocate --region-id de1 --tags project=storefrontPOST /ec2/api/elastic-ips
{ "regionId": "de1", "tags": { "project": "storefront" } }resource "dcloud_eip" "web" {
tags = { project = "storefront" }
}Attach it to an instance
- Open the instance, then choose Networking.
- Under Elastic IP, choose Associate.
- In Associate Elastic IP, for Elastic IP, choose the address (or allocate one there), then choose Associate.
Or, on Elastic IPs, choose Associate with instance in the address's row menu.
dcloud ec2 elastic-ips associate eip-uuid --instance-id i-3f9a2c07POST /ec2/api/elastic-ips/0ea56c91-0000-4000-8000-000000000004/associate
{ "instanceId": "i-3f9a2c07" }resource "dcloud_eip_association" "web" {
elastic_ip_id = dcloud_eip.web.id
instance_id = dcloud_instance.web.id
}An address that is already associated is refused with 400 "IP is already associated.
Disassociate it first"; an instance whose machine does not exist yet with 409 "Instance has no
backing server yet". An address with no tags takes the instance's tags when it is associated; tags
it already has are never overwritten.
Instances launched since 17 November 2026 bind the address themselves within 20 seconds. On an older instance the address does not answer until you run the commands the address's details show under On the machine (Ubuntu or Debian with netplan), once, as root. The details say Active on the machine once the machine has bound it.
Move or detach it
On Elastic IPs, choose Disassociate in the address's row menu, then choose Disassociate in the dialog; or, on the instance's Networking tab, under Elastic IP, choose Disassociate (it takes effect at once, without a dialog). Then associate it with the other instance.
dcloud ec2 elastic-ips disassociate eip-uuidPOST /ec2/api/elastic-ips/0ea56c91-0000-4000-8000-000000000004/disassociateChange instance_id on the dcloud_eip_association (Terraform replaces the association), or remove
it.
The address stays allocated and metered. Disassociating an address that is not attached is refused
with 400 "IP is not associated with any instance". Terminating the instance disassociates it as
well.
Release it
- On Elastic IPs, choose the address to open its side panel.
- Under Release this address, choose Release address.
- Enter the address and choose Release.
dcloud ec2 elastic-ips release eip-uuidDELETE /ec2/api/elastic-ips/0ea56c91-0000-4000-8000-000000000004Remove the dcloud_eip resource and run terraform apply.
Releasing an attached address is refused with 400 "Disassociate the IP from its instance before
releasing". A released address returns to the pool and cannot be reclaimed.