diff --git a/README.md b/README.md index bdeef60b..cf0df7b4 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ module "vpc" { range_name = "subnet-01-secondary-01" ip_cidr_range = "192.168.64.0/24" }, + { + range_name = "subnet-01-secondary-02" + reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range" + }, ] subnet-02 = [] @@ -128,7 +132,7 @@ Then perform the following commands on the root folder: | project\_id | The ID of the project where this VPC will be created | `string` | n/a | yes | | routes | List of routes being created in this VPC | `list(map(string))` | `[]` | no | | routing\_mode | The network routing mode (default 'GLOBAL') | `string` | `"GLOBAL"` | no | -| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no | +| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))` | `{}` | no | | shared\_vpc\_host | Makes this project a Shared VPC host if 'true' (default 'false') | `bool` | `false` | no | | subnets | The list of subnets being created |
list(object({
subnet_name = string
subnet_ip = string
subnet_region = string
subnet_private_access = optional(string)
subnet_private_ipv6_access = optional(string)
subnet_flow_logs = optional(string)
subnet_flow_logs_interval = optional(string)
subnet_flow_logs_sampling = optional(string)
subnet_flow_logs_metadata = optional(string)
subnet_flow_logs_filter = optional(string)
subnet_flow_logs_metadata_fields = optional(list(string))
description = optional(string)
purpose = optional(string)
role = optional(string)
stack_type = optional(string)
ipv6_access_type = optional(string)
}))
| n/a | yes | diff --git a/examples/secondary_ranges/README.md b/examples/secondary_ranges/README.md index 3a96f31f..8c097fe1 100644 --- a/examples/secondary_ranges/README.md +++ b/examples/secondary_ranges/README.md @@ -17,6 +17,8 @@ ranges and the third being given a single secondary range. | Name | Description | |------|-------------| +| internal\_range\_id | The ID of the created internal range | +| internal\_range\_name | The name of the created internal range | | network\_name | The name of the VPC being created | | network\_self\_link | The URI of the VPC being created | | project\_id | VPC project id | diff --git a/examples/secondary_ranges/main.tf b/examples/secondary_ranges/main.tf index acd31e3a..93547bd6 100644 --- a/examples/secondary_ranges/main.tf +++ b/examples/secondary_ranges/main.tf @@ -76,6 +76,10 @@ module "vpc-secondary-ranges" { range_name = "${local.subnet_03}-01" ip_cidr_range = "192.168.66.0/24" }, + { + range_name = "${local.subnet_03}-02" + reserved_internal_range = "networkconnectivity.googleapis.com/${google_network_connectivity_internal_range.internal_range.id}" + }, ] } @@ -103,3 +107,13 @@ module "vpc-secondary-ranges" { }, ] } + +resource "google_network_connectivity_internal_range" "internal_range" { + project = var.project_id + name = "${var.network_name}-internal-range" + description = "Example internal range for secondary subnet ranges" + ip_cidr_range = "172.16.0.0/24" + network = module.vpc-secondary-ranges.network_id + usage = "FOR_VPC" + peering = "FOR_SELF" +} diff --git a/examples/secondary_ranges/outputs.tf b/examples/secondary_ranges/outputs.tf index 6c3f49cb..432f5c02 100644 --- a/examples/secondary_ranges/outputs.tf +++ b/examples/secondary_ranges/outputs.tf @@ -63,3 +63,13 @@ output "route_names" { value = module.vpc-secondary-ranges.route_names description = "The routes associated with this VPC" } + +output "internal_range_id" { + value = google_network_connectivity_internal_range.internal_range.id + description = "The ID of the created internal range" +} + +output "internal_range_name" { + value = google_network_connectivity_internal_range.internal_range.name + description = "The name of the created internal range" +} diff --git a/examples/secondary_ranges/versions.tf b/examples/secondary_ranges/versions.tf index 956bac1d..f51e6b71 100644 --- a/examples/secondary_ranges/versions.tf +++ b/examples/secondary_ranges/versions.tf @@ -19,7 +19,8 @@ terraform { required_providers { google = { - source = "hashicorp/google" + source = "hashicorp/google" + version = ">= 6.0" } null = { version = ">= 3.0" diff --git a/metadata.yaml b/metadata.yaml index ce279bbd..f3f9d443 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -158,7 +158,7 @@ spec: required: true - name: secondary_ranges description: Secondary ranges that will be used in some of the subnets - varType: map(list(object({ range_name = string, ip_cidr_range = string }))) + varType: map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) }))) defaultValue: {} - name: routes description: List of routes being created in this VPC @@ -354,6 +354,6 @@ spec: - servicenetworking.googleapis.com providerVersions: - source: hashicorp/google - version: ">= 4.64, < 8" + version: ">= 6.0, < 8" - source: hashicorp/google-beta - version: ">= 4.64, < 8" + version: ">= 6.0, < 8" diff --git a/modules/subnets-beta/README.md b/modules/subnets-beta/README.md index 773b6cf3..d15b429e 100644 --- a/modules/subnets-beta/README.md +++ b/modules/subnets-beta/README.md @@ -52,6 +52,10 @@ module "vpc" { range_name = "subnet-01-secondary-01" ip_cidr_range = "192.168.64.0/24" }, + { + range_name = "subnet-01-secondary-02" + reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range" + }, ] subnet-02 = [] @@ -67,7 +71,7 @@ module "vpc" { | module\_depends\_on | List of modules or resources this module depends on. | `list(any)` | `[]` | no | | network\_name | The name of the network where subnets will be created | `string` | n/a | yes | | project\_id | The ID of the project where subnets will be created | `string` | n/a | yes | -| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no | +| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))` | `{}` | no | | subnets | The list of subnets being created |
list(object({
subnet_name = string
subnet_ip = string
subnet_region = string
subnet_private_access = optional(string, "false")
subnet_private_ipv6_access = optional(string)
subnet_flow_logs = optional(bool, false)
subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
subnet_flow_logs_sampling = optional(string, "0.5")
subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
subnet_flow_logs_filter = optional(string, "true")
subnet_flow_logs_metadata_fields = optional(list(string), [])
description = optional(string)
purpose = optional(string)
role = optional(string)
stack_type = optional(string)
ipv6_access_type = optional(string)
}))
| n/a | yes | ## Outputs diff --git a/modules/subnets-beta/main.tf b/modules/subnets-beta/main.tf index c35f4a49..87308621 100644 --- a/modules/subnets-beta/main.tf +++ b/modules/subnets-beta/main.tf @@ -56,8 +56,9 @@ resource "google_compute_subnetwork" "subnetwork" { for_each = contains(keys(var.secondary_ranges), each.value.subnet_name) == true ? var.secondary_ranges[each.value.subnet_name] : [] content { - range_name = secondary_ip_range.value.range_name - ip_cidr_range = secondary_ip_range.value.ip_cidr_range + range_name = secondary_ip_range.value.range_name + ip_cidr_range = secondary_ip_range.value.ip_cidr_range + reserved_internal_range = secondary_ip_range.value.reserved_internal_range } } diff --git a/modules/subnets-beta/metadata.yaml b/modules/subnets-beta/metadata.yaml index 442ab4ef..abe1d1e2 100644 --- a/modules/subnets-beta/metadata.yaml +++ b/modules/subnets-beta/metadata.yaml @@ -122,7 +122,7 @@ spec: required: true - name: secondary_ranges description: Secondary ranges that will be used in some of the subnets - varType: map(list(object({ range_name = string, ip_cidr_range = string }))) + varType: map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) }))) defaultValue: {} - name: module_depends_on description: List of modules or resources this module depends on. @@ -161,4 +161,4 @@ spec: - servicenetworking.googleapis.com providerVersions: - source: hashicorp/google-beta - version: ">= 2.19, < 8" + version: ">= 6.0, < 8" diff --git a/modules/subnets-beta/variables.tf b/modules/subnets-beta/variables.tf index 114eed4b..f621571b 100644 --- a/modules/subnets-beta/variables.tf +++ b/modules/subnets-beta/variables.tf @@ -47,7 +47,7 @@ variable "subnets" { } variable "secondary_ranges" { - type = map(list(object({ range_name = string, ip_cidr_range = string }))) + type = map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) }))) description = "Secondary ranges that will be used in some of the subnets" default = {} } diff --git a/modules/subnets-beta/versions.tf b/modules/subnets-beta/versions.tf index 7f5fc015..b0f321f0 100644 --- a/modules/subnets-beta/versions.tf +++ b/modules/subnets-beta/versions.tf @@ -20,7 +20,7 @@ terraform { required_providers { google-beta = { source = "hashicorp/google-beta" - version = ">= 2.19, < 8" + version = ">= 6.0, < 8" } } diff --git a/modules/subnets/README.md b/modules/subnets/README.md index 74266c59..1f80934d 100644 --- a/modules/subnets/README.md +++ b/modules/subnets/README.md @@ -52,6 +52,10 @@ module "vpc" { range_name = "subnet-01-secondary-01" ip_cidr_range = "192.168.64.0/24" }, + { + range_name = "subnet-01-secondary-02" + reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range" + }, ] subnet-02 = [] @@ -66,7 +70,7 @@ module "vpc" { |------|-------------|------|---------|:--------:| | network\_name | The name of the network where subnets will be created | `string` | n/a | yes | | project\_id | The ID of the project where subnets will be created | `string` | n/a | yes | -| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no | +| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))` | `{}` | no | | subnets | The list of subnets being created |
list(object({
subnet_name = string
subnet_ip = string
subnet_region = string
subnet_private_access = optional(string, "false")
subnet_private_ipv6_access = optional(string)
subnet_flow_logs = optional(string, "false")
subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
subnet_flow_logs_sampling = optional(string, "0.5")
subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
subnet_flow_logs_filter = optional(string, "true")
subnet_flow_logs_metadata_fields = optional(list(string), [])
description = optional(string)
purpose = optional(string)
role = optional(string)
stack_type = optional(string)
ipv6_access_type = optional(string)
}))
| n/a | yes | ## Outputs diff --git a/modules/subnets/main.tf b/modules/subnets/main.tf index 01aea2f6..536435c9 100644 --- a/modules/subnets/main.tf +++ b/modules/subnets/main.tf @@ -56,8 +56,9 @@ resource "google_compute_subnetwork" "subnetwork" { for_each = contains(keys(var.secondary_ranges), each.value.subnet_name) == true ? var.secondary_ranges[each.value.subnet_name] : [] content { - range_name = secondary_ip_range.value.range_name - ip_cidr_range = secondary_ip_range.value.ip_cidr_range + range_name = secondary_ip_range.value.range_name + ip_cidr_range = secondary_ip_range.value.ip_cidr_range + reserved_internal_range = secondary_ip_range.value.reserved_internal_range } } diff --git a/modules/subnets/metadata.yaml b/modules/subnets/metadata.yaml index 69e071b9..1937ccec 100644 --- a/modules/subnets/metadata.yaml +++ b/modules/subnets/metadata.yaml @@ -122,7 +122,7 @@ spec: required: true - name: secondary_ranges description: Secondary ranges that will be used in some of the subnets - varType: map(list(object({ range_name = string, ip_cidr_range = string }))) + varType: map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) }))) defaultValue: {} outputs: - name: subnets @@ -157,4 +157,4 @@ spec: - servicenetworking.googleapis.com providerVersions: - source: hashicorp/google - version: ">= 4.25.0, < 8" + version: ">= 6.0, < 8" diff --git a/modules/subnets/variables.tf b/modules/subnets/variables.tf index 6992f128..24d715e1 100644 --- a/modules/subnets/variables.tf +++ b/modules/subnets/variables.tf @@ -47,7 +47,7 @@ variable "subnets" { } variable "secondary_ranges" { - type = map(list(object({ range_name = string, ip_cidr_range = string }))) + type = map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) }))) description = "Secondary ranges that will be used in some of the subnets" default = {} } diff --git a/modules/subnets/versions.tf b/modules/subnets/versions.tf index f6b5ac70..e8059d7a 100644 --- a/modules/subnets/versions.tf +++ b/modules/subnets/versions.tf @@ -20,7 +20,7 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = ">= 4.25.0, < 8" + version = ">= 6.0, < 8" } } diff --git a/variables.tf b/variables.tf index da57542f..add3ebd7 100644 --- a/variables.tf +++ b/variables.tf @@ -59,7 +59,7 @@ variable "subnets" { } variable "secondary_ranges" { - type = map(list(object({ range_name = string, ip_cidr_range = string }))) + type = map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) }))) description = "Secondary ranges that will be used in some of the subnets" default = {} } diff --git a/versions.tf b/versions.tf index d2fa089b..695d775c 100644 --- a/versions.tf +++ b/versions.tf @@ -19,11 +19,11 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = ">= 4.64, < 8" + version = ">= 6.0, < 8" } google-beta = { source = "hashicorp/google-beta" - version = ">= 4.64, < 8" + version = ">= 6.0, < 8" } }