Resource: aws_vpc_ipam_pool_cidr_allocation

Allocates (reserves) a CIDR from an IPAM address pool, preventing usage by IPAM. Only works for private IPv4.

Example Usage

Basic usage:

data "aws_region" "current" {}

resource "aws_vpc_ipam_pool_cidr_allocation" "example" {
  ipam_pool_id = aws_vpc_ipam_pool.example.id
  cidr         = "172.20.0.0/24"
  depends_on = [
    aws_vpc_ipam_pool_cidr.example
  ]
}

resource "aws_vpc_ipam_pool_cidr" "example" {
  ipam_pool_id = aws_vpc_ipam_pool.example.id
  cidr         = "172.20.0.0/16"
}

resource "aws_vpc_ipam_pool" "example" {
  address_family = "ipv4"
  ipam_scope_id  = aws_vpc_ipam.example.private_default_scope_id
  locale         = data.aws_region.current.name
}

resource "aws_vpc_ipam" "example" {
  operating_regions {
    region_name = data.aws_region.current.name
  }
}

With the disallowed_cidrs attribute:

data "aws_region" "current" {}

resource "aws_vpc_ipam_pool_cidr_allocation" "example" {
  ipam_pool_id   = aws_vpc_ipam_pool.example.id
  netmask_length = 28

  disallowed_cidrs = [
    "172.20.0.0/28"
  ]

  depends_on = [
    aws_vpc_ipam_pool_cidr.example
  ]
}

resource "aws_vpc_ipam_pool_cidr" "example" {
  ipam_pool_id = aws_vpc_ipam_pool.example.id
  cidr         = "172.20.0.0/16"
}

resource "aws_vpc_ipam_pool" "example" {
  address_family = "ipv4"
  ipam_scope_id  = aws_vpc_ipam.example.private_default_scope_id
  locale         = data.aws_region.current.name
}

resource "aws_vpc_ipam" "example" {
  operating_regions {
    region_name = data.aws_region.current.name
  }
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import IPAM allocations using the allocation id and pool id, separated by _. For example:

import {
  to = aws_vpc_ipam_pool_cidr_allocation.example
  id = "ipam-pool-alloc-0dc6d196509c049ba8b549ff99f639736_ipam-pool-07cfb559e0921fcbe"
}

Using terraform import, import IPAM allocations using the allocation id and pool id, separated by _. For example:

% terraform import aws_vpc_ipam_pool_cidr_allocation.example ipam-pool-alloc-0dc6d196509c049ba8b549ff99f639736_ipam-pool-07cfb559e0921fcbe