Allocates a CIDR block with specific subnets disallowed within an IPAM pool, enhancing control over subnet usage.

Terraform Template

data "aws_region" "current" {
}

resource "aws_vpc_ipam" "example" {

  operating_regions {
    region_name = data.aws_region.current.name
  }
}

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_pool_cidr" "example" {
  cidr = "172.20.0.0/16"
  ipam_pool_id = aws_vpc_ipam_pool.example.id
}

resource "aws_vpc_ipam_pool_cidr_allocation" "example" {
  depends_on = ["aws_vpc_ipam_pool_cidr.example"]
  disallowed_cidrs = ["172.20.0.0/28"]
  ipam_pool_id = aws_vpc_ipam_pool.example.id
  netmask_length = 28
}