Provisions a CIDR from an IPAM address pool.
Basic usage:
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" {
ipam_pool_id = aws_vpc_ipam_pool.example.id
cidr = "172.20.0.0/16"
}
Provision Public IPv6 Pool CIDRs:
data "aws_region" "current" {}
resource "aws_vpc_ipam" "example" {
operating_regions {
region_name = data.aws_region.current.name
}
}
resource "aws_vpc_ipam_pool" "ipv6_test_public" {
address_family = "ipv6"
ipam_scope_id = aws_vpc_ipam.example.public_default_scope_id
locale = "us-east-1"
description = "public ipv6"
publicly_advertisable = false
public_ip_source = "amazon"
aws_service = "ec2"
}
resource "aws_vpc_ipam_pool_cidr" "ipv6_test_public" {
ipam_pool_id = aws_vpc_ipam_pool.ipv6_test_public.id
netmask_length = 52
}
This resource supports the following arguments:
cidr
- (Optional) The CIDR you want to assign to the pool. Conflicts with netmask_length
.cidr_authorization_context
- (Optional) A signed document that proves that you are authorized to bring the specified IP address range to Amazon using BYOIP. This is not stored in the state file. See cidr_authorization_context for more information.ipam_pool_id
- (Required) The ID of the pool to which you want to assign a CIDR.netmask_length
- (Optional) If provided, the cidr provisioned into the specified pool will be the next available cidr given this declared netmask length. Conflicts with cidr
.message
- (Optional) The plain-text authorization message for the prefix and account.signature
- (Optional) The signed authorization message for the prefix and account.This resource exports the following attributes in addition to the arguments above:
id
- The ID of the IPAM Pool Cidr concatenated with the IPAM Pool ID.ipam_pool_cidr_id
- The unique ID generated by AWS for the pool cidr. Typically this is the resource id
but this attribute was added to the API calls after the fact and is therefore not used as the terraform resource id.In Terraform v1.5.0 and later, use an import
block to import IPAMs using the <cidr>_<ipam-pool-id>
. For example:
NOTE: Do not use the IPAM Pool Cidr ID as this was introduced after the resource already existed.
import {
to = aws_vpc_ipam_pool_cidr.example
id = "172.20.0.0/24_ipam-pool-0e634f5a1517cccdc"
}
Using terraform import
, import IPAMs using the <cidr>_<ipam-pool-id>
. For example:
NOTE: Do not use the IPAM Pool Cidr ID as this was introduced after the resource already existed.
% terraform import aws_vpc_ipam_pool_cidr.example 172.20.0.0/24_ipam-pool-0e634f5a1517cccdc