Skip to content

googleNetblockIpRanges

Use this data source to get the IP addresses from different special IP ranges on Google Cloud Platform.

Example Usage - Cloud Ranges

import * as cdktf from "cdktf";
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const dataGoogleNetblockIpRangesNetblock =
  new google.dataGoogleNetblockIpRanges.DataGoogleNetblockIpRanges(
    this,
    "netblock",
    {}
  );
new cdktf.TerraformOutput(this, "cidr_blocks", {
  value: dataGoogleNetblockIpRangesNetblock.cidrBlocks,
});
new cdktf.TerraformOutput(this, "cidr_blocks_ipv4", {
  value: dataGoogleNetblockIpRangesNetblock.cidrBlocksIpv4,
});
new cdktf.TerraformOutput(this, "cidr_blocks_ipv6", {
  value: dataGoogleNetblockIpRangesNetblock.cidrBlocksIpv6,
});

Example Usage - Allow Health Checks

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkDefault = new google.computeNetwork.ComputeNetwork(
  this,
  "default",
  {
    name: "test-network",
  }
);
const dataGoogleNetblockIpRangesLegacyHcs =
  new google.dataGoogleNetblockIpRanges.DataGoogleNetblockIpRanges(
    this,
    "legacy-hcs",
    {
      range_type: "legacy-health-checkers",
    }
  );
new google.computeFirewall.ComputeFirewall(this, "allow-hcs", {
  allow: [
    {
      ports: ["80"],
      protocol: "tcp",
    },
  ],
  name: "allow-hcs",
  network: googleComputeNetworkDefault.name,
  source_ranges: dataGoogleNetblockIpRangesLegacyHcs.cidrBlocksIpv4,
});

Argument Reference

The following arguments are supported:

  • rangeType (Optional) - The type of range for which to provide results.

    Defaults to cloudNetblocks. The following rangeTypes are supported:

    • cloudNetblocks - Corresponds to the IP addresses used for resources on Google Cloud Platform. More details.

    • googleNetblocks - Corresponds to IP addresses used for Google services. More details.

    • restrictedGoogleapis - Corresponds to the IP addresses used for Private Google Access only for services that support VPC Service Controls API access. More details.

    • privateGoogleapis - Corresponds to the IP addresses used for Private Google Access for services that do not support VPC Service Controls. More details.

    • dnsForwarders - Corresponds to the IP addresses used to originate Cloud DNS outbound forwarding. More details.

    • iapForwarders - Corresponds to the IP addresses used for Cloud IAP for TCP forwarding. More details.

    • healthCheckers - Corresponds to the IP addresses used for health checking in Cloud Load Balancing. More details.

    • legacyHealthCheckers - Corresponds to the IP addresses used for legacy style health checkers (used by Network Load Balancing). More details.

Attributes Reference

  • cidrBlocks - Retrieve list of all CIDR blocks.

  • cidrBlocksIpv4 - Retrieve list of the IPv4 CIDR blocks

  • cidrBlocksIpv6 - Retrieve list of the IPv6 CIDR blocks, if available.