Skip to content

Data Source: awsIpRanges

Use this data source to get the IP ranges of various AWS products and services. For more information about the contents of this data source and required JSON syntax if referencing a custom URL, see the AWS IP Address Ranges documentation.

Example 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 dataAwsIpRangesEuropeanEc2 = new aws.dataAwsIpRanges.DataAwsIpRanges(
  this,
  "european_ec2",
  {
    regions: ["eu-west-1", "eu-central-1"],
    services: ["ec2"],
  }
);
new aws.securityGroup.SecurityGroup(this, "from_europe", {
  ingress: [
    {
      cidrBlocks: dataAwsIpRangesEuropeanEc2.cidrBlocks,
      fromPort: "443",
      ipv6CidrBlocks: dataAwsIpRangesEuropeanEc2.ipv6CidrBlocks,
      protocol: "tcp",
      toPort: "443",
    },
  ],
  name: "from_europe",
  tags: {
    CreateDate: dataAwsIpRangesEuropeanEc2.createDate,
    SyncToken: dataAwsIpRangesEuropeanEc2.syncToken,
  },
});

Argument Reference

  • regions - (Optional) Filter IP ranges by regions (or include all regions, if omitted). Valid items are global (for cloudfront) as well as all AWS regions (e.g., euCentral1)

  • services - (Required) Filter IP ranges by services. Valid items are amazon (for amazon.com), amazonConnect, apiGateway, cloud9, cloudfront, codebuild, dynamodb, ec2, ec2InstanceConnect, globalaccelerator, route53, route53Healthchecks, s3 and workspacesGateways. See the service attribute documentation for other possible values.

\~> NOTE: If the specified combination of regions and services does not yield any CIDR blocks, Terraform will fail.

Attributes Reference

  • cidrBlocks - Lexically ordered list of CIDR blocks.
  • ipv6CidrBlocks - Lexically ordered list of IPv6 CIDR blocks.
  • createDate - Publication time of the IP ranges (e.g., 20160803234605).
  • syncToken - Publication time of the IP ranges, in Unix epoch time format (e.g., 1470267965).