Skip to content

Data Source: awsVpcIpamPoolCidrs

awsVpcIpamPoolCidrs provides details about an IPAM pool.

This resource can prove useful when an ipam pool was shared to your account and you want to know all (or a filtered list) of the CIDRs that are provisioned into the pool.

Example Usage

Basic usage:

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const dataAwsVpcIpamPoolP = new aws.dataAwsVpcIpamPool.DataAwsVpcIpamPool(
  this,
  "p",
  {
    filter: [
      {
        name: "description",
        values: ["*mypool*"],
      },
      {
        name: "address-family",
        values: ["ipv4"],
      },
    ],
  }
);
new aws.dataAwsVpcIpamPoolCidrs.DataAwsVpcIpamPoolCidrs(this, "c", {
  ipamPoolId: dataAwsVpcIpamPoolP.id,
});

Filtering:

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const mycidrs = [
  '${[for cidr in data.aws_vpc_ipam_pool_cidrs.c.ipam_pool_cidrs :\n    cidr.cidr if\n  cidr.state == "provisioned"]}',
];
const awsEc2ManagedPrefixListPls =
  new aws.ec2ManagedPrefixList.Ec2ManagedPrefixList(this, "pls", {
    addressFamily: "IPv4",
    entry: [],
    maxEntries: `\${length(${mycidrs})}`,
    name: "IPAM Pool (${aws_vpc_ipam_pool.test.id}) Cidrs",
  });
/*In most cases loops should be handled in the programming language context and 
not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
you need to keep this like it is.*/
awsEc2ManagedPrefixListPls.addOverride("entry", {
  for_each: mycidrs,
  content: [
    {
      cidr: "${entry.value}",
      description: "${entry.value}",
    },
  ],
});
new aws.dataAwsVpcIpamPoolCidrs.DataAwsVpcIpamPoolCidrs(this, "c", {
  filter: [
    {
      name: "cidr",
      values: ["10.*"],
    },
  ],
  ipamPoolId: "ipam-pool-123",
});

Argument Reference

The arguments of this data source act as filters for querying the available VPCs in the current region. The given filters must match exactly one VPC whose data will be exported as attributes.

  • ipamPoolId - ID of the IPAM pool you would like the list of provisioned CIDRs.
  • filter - Custom filter block as described below.

Attributes Reference

All of the argument attributes except filter blocks are also exported as result attributes. This data source will complete the data by populating any fields that are not included in the configuration with the data for the selected IPAM Pool CIDRs.

The following attribute is additionally exported:

  • ipamPoolCidrs - The CIDRs provisioned into the IPAM pool, described below.

ipamPoolCidrs

  • cidr - A network CIDR.
  • state - The provisioning state of that CIDR.

Timeouts

Configuration options:

  • read - (Default 1M)