Use this data source to get the IP addresses from different special IP ranges on Google Cloud Platform.
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
}
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"
}
The following arguments are supported:
range_type
(Optional) - The type of range for which to provide results.
Defaults to cloud-netblocks
. The following range_type
s are supported:
cloud-netblocks
- Corresponds to the IP addresses used for resources on Google Cloud Platform. More details.
google-netblocks
- Corresponds to IP addresses used for Google services. More details.
restricted-googleapis
- Corresponds to the IP addresses used for Private Google Access only for services that support VPC Service Controls API access. More details.
private-googleapis
- Corresponds to the IP addresses used for Private Google Access for services that do not support VPC Service Controls. More details.
dns-forwarders
- Corresponds to the IP addresses used to originate Cloud DNS outbound forwarding. More details.
iap-forwarders
- Corresponds to the IP addresses used for Cloud IAP for TCP forwarding. More details.
health-checkers
- Corresponds to the IP addresses used for health checking in Cloud Load Balancing. More details.
legacy-health-checkers
- Corresponds to the IP addresses used for legacy style health checkers (used by Network Load Balancing). More details.
cidr_blocks
- Retrieve list of all CIDR blocks.
cidr_blocks_ipv4
- Retrieve list of the IPv4 CIDR blocks
cidr_blocks_ipv6
- Retrieve list of the IPv6 CIDR blocks, if available.