Skip to content

Data Source: awsEc2ManagedPrefixLists

This resource can be useful for getting back a list of managed prefix list ids to be referenced elsewhere.

Example Usage

The following returns all managed prefix lists filtered by tags

/*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 dataAwsEc2ManagedPrefixListsTestEnv =
  new aws.dataAwsEc2ManagedPrefixLists.DataAwsEc2ManagedPrefixLists(
    this,
    "test_env",
    {
      tags: {
        Env: "test",
      },
    }
  );
const dataAwsEc2ManagedPrefixListTestEnv =
  new aws.dataAwsEc2ManagedPrefixList.DataAwsEc2ManagedPrefixList(
    this,
    "test_env_1",
    {
      id: `\${tolist(${dataAwsEc2ManagedPrefixListsTestEnv.ids})[count.index]}`,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAwsEc2ManagedPrefixListTestEnv.overrideLogicalId("test_env");
/*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.*/
dataAwsEc2ManagedPrefixListTestEnv.addOverride(
  "count",
  `\${length(${dataAwsEc2ManagedPrefixListsTestEnv.ids})}`
);

Argument Reference

  • filter - (Optional) Custom filter block as described below.
  • tags - (Optional) Map of tags, each pair of which must exactly match a pair on the desired .

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

  • name - (Required) Name of the field to filter by, as defined by the underlying AWS API.
  • values - (Required) Set of values that are accepted for the given field. A managed prefix list will be selected if any one of the given values matches.

Attributes Reference

  • id - AWS Region.
  • ids - List of all the managed prefix list ids found.

Timeouts

Configuration options:

  • read - (Default 20M)