The internal range resource for IPAM operations within a VPC network. Used to represent a private address range along with behavioral characterstics of that range (its usage and peering behavior). Networking resources can link to this range if they are created as belonging to it.
To get more information about InternalRange, see:
resource "google_network_connectivity_internal_range" "default" {
name = "basic"
description = "Test internal range"
network = google_compute_network.default.self_link
usage = "FOR_VPC"
peering = "FOR_SELF"
ip_cidr_range = "10.0.0.0/24"
labels = {
label-a: "b"
}
}
resource "google_compute_network" "default" {
name = "internal-ranges"
auto_create_subnetworks = false
}
resource "google_network_connectivity_internal_range" "default" {
name = "automatic-reservation"
network = google_compute_network.default.id
usage = "FOR_VPC"
peering = "FOR_SELF"
prefix_length = 24
target_cidr_range = [
"192.16.0.0/16"
]
}
resource "google_compute_network" "default" {
name = "internal-ranges"
auto_create_subnetworks = false
}
resource "google_network_connectivity_internal_range" "default" {
name = "external-ranges"
network = google_compute_network.default.id
usage = "EXTERNAL_TO_VPC"
peering = "FOR_SELF"
ip_cidr_range = "172.16.0.0/24"
labels = {
external-reserved-range: "on-premises"
}
}
resource "google_compute_network" "default" {
name = "internal-ranges"
auto_create_subnetworks = false
}
resource "google_network_connectivity_internal_range" "default" {
name = "overlap-range"
description = "Test internal range"
network = google_compute_network.default.id
usage = "FOR_VPC"
peering = "FOR_SELF"
ip_cidr_range = "10.0.0.0/30"
overlaps = [
"OVERLAP_EXISTING_SUBNET_RANGE"
]
depends_on = [
google_compute_subnetwork.default
]
}
resource "google_compute_network" "default" {
name = "internal-ranges"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "default" {
name = "overlapping-subnet"
ip_cidr_range = "10.0.0.0/24"
region = "us-central1"
network = google_compute_network.default.id
}
The following arguments are supported:
name
-
(Required)
The name of the policy based route.
network
-
(Required)
Fully-qualified URL of the network that this route applies to, for example: projects/my-project/global/networks/my-network.
usage
-
(Required)
The type of usage set for this InternalRange.
Possible values are: FOR_VPC
, EXTERNAL_TO_VPC
.
peering
-
(Required)
The type of peering set for this internal range.
Possible values are: FOR_SELF
, FOR_PEER
, NOT_SHARED
.
labels
-
(Optional)
User-defined labels.
Note: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field effective_labels
for all of the labels present on the resource.
description
-
(Optional)
An optional description of this resource.
ip_cidr_range
-
(Optional)
The IP range that this internal range defines.
prefix_length
-
(Optional)
An alternate to ipCidrRange. Can be set when trying to create a reservation that automatically finds a free range of the given size.
If both ipCidrRange and prefixLength are set, there is an error if the range sizes do not match. Can also be used during updates to change the range size.
target_cidr_range
-
(Optional)
Optional. Can be set to narrow down or pick a different address space while searching for a free range.
If not set, defaults to the "10.0.0.0/8" address space. This can be used to search in other rfc-1918 address spaces like "172.16.0.0/12" and "192.168.0.0/16" or non-rfc-1918 address spaces used in the VPC.
overlaps
-
(Optional)
Optional. Types of resources that are allowed to overlap with the current internal range.
Each value may be one of: OVERLAP_ROUTE_RANGE
, OVERLAP_EXISTING_SUBNET_RANGE
.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format projects/{{project}}/locations/global/internalRanges/{{name}}
users
-
Output only. The list of resources that refer to this internal range.
Resources that use the internal range for their range allocation are referred to as users of the range.
Other resources mark themselves as users while doing so by creating a reference to this internal range. Having a user, based on this reference, prevents deletion of the internal range referred to. Can be empty.
terraform_labels
-
The combination of labels configured directly on the resource
and default labels configured on the provider.
effective_labels
-
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
This resource provides the following Timeouts configuration options:
create
- Default is 30 minutes.update
- Default is 30 minutes.delete
- Default is 30 minutes.InternalRange can be imported using any of these accepted formats:
projects/{{project}}/locations/global/internalRanges/{{name}}
{{project}}/{{name}}
{{name}}
In Terraform v1.5.0 and later, use an import
block to import InternalRange using one of the formats above. For example:
import {
id = "projects/{{project}}/locations/global/internalRanges/{{name}}"
to = google_network_connectivity_internal_range.default
}
When using the terraform import
command, InternalRange can be imported using one of the formats above. For example:
$ terraform import google_network_connectivity_internal_range.default projects/{{project}}/locations/global/internalRanges/{{name}}
$ terraform import google_network_connectivity_internal_range.default {{project}}/{{name}}
$ terraform import google_network_connectivity_internal_range.default {{name}}
This resource supports User Project Overrides.