» google_netblock_ip_ranges

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

» Example Usage - Cloud Ranges

data "google_netblock_ip_ranges" "netblock" {}

output "cidr_blocks" {
  value = "${data.google_netblock_ip_ranges.netblock.cidr_blocks}"
}

output "cidr_blocks_ipv4" {
  value = "${data.google_netblock_ip_ranges.netblock.cidr_blocks_ipv4}"
}

output "cidr_blocks_ipv6" {
  value = "${data.google_netblock_ip_ranges.netblock.cidr_blocks_ipv6}"
}

» Example Usage - Allow Health Checks

data "google_netblock_ip_ranges" "legacy-hcs" {
  range_type = "legacy-health-checkers"
}

resource "google_compute_firewall" "allow-hcs" {
  name    = "allow-hcs"
  network = "${google_compute_network.default.name}"

  allow {
    protocol = "tcp"
    ports    = ["80"]
  }

  source_ranges = ["${data.google_netblock_ip_ranges.legacy-hcs.cidr_blocks_ipv4}"]
}

resource "google_compute_network" "default" {
  name = "test-network"
}

» Argument Reference

The following arguments are supported:

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

Defaults to cloud-netblocks. The following range_types are supported:

» Attributes Reference