Skip to main content

~> Deprecation Notice Equinix Metal will reach end of life on June 30, 2026. All Metal resources will be removed in version 5.0.0 of this provider. Use version 4.x of this provider for continued use through sunset. See https://docs.equinix.com/metal/ for more information.

equinix_metal_ip_attachment (Resource)

Provides a resource to attach elastic IP subnets to devices.

To attach an IP subnet from a reserved block to a provisioned device, you must derive a subnet CIDR belonging to one of your reserved blocks in the same project and metro as the target device.

For example, you have reserved IPv4 address block 147.229.10.152/30, you can choose to assign either the whole block as one subnet to a device; or 2 subnets with CIDRs 147.229.10.152/31 and 147.229.10.154/31; or 4 subnets with mask prefix length 32. More about the elastic IP subnets is here.

Device and reserved block must be in the same metro.

Example Usage

# Reserve /30 block of max 2 public IPv4 addresses in metro ny for myproject
resource "equinix_metal_reserved_ip_block" "myblock" {
project_id = local.project_id
metro = "ny"
quantity = 2
}

# Assign /32 subnet (single address) from reserved block to a device
resource "equinix_metal_ip_attachment" "first_address_assignment" {
device_id = equinix_metal_device.mydevice.id
# following expression will result to sth like "147.229.10.152/32"
cidr_notation = join("/", [cidrhost(metal_reserved_ip_block.myblock.cidr_notation, 0), "32"])
}

Argument Reference

The following arguments are supported:

  • device_id - (Required) ID of device to which to assign the subnet.
  • cidr_notation - (Required) CIDR notation of subnet from block reserved in the same project and metro as the device.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The unique ID of the assignment.
  • device_id - ID of device to which subnet is assigned.
  • cidr_notation - Assigned subnet in CIDR notation, e.g., 147.229.15.30/31
  • gateway - IP address of gateway for the subnet.
  • network - Subnet network address.
  • netmask - Subnet mask in decimal notation, e.g., 255.255.255.0.
  • cidr - Length of CIDR prefix of the subnet as integer.
  • address_family - Address family as integer. One of 4 or 6.
  • public - Boolean flag whether subnet is reachable from the Internet.
Was this page helpful?