Add support for subnetwork for external addresses
For IPv6 it is necessary to provide subnetwork when reserving external address.
This commit is contained in:
committed by
Wiktor Niesiobędzki
parent
b92135a56d
commit
39822888ad
@@ -136,13 +136,13 @@ module "addresses" {
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [project_id](variables.tf#L83) | Project where the addresses will be created. | <code>string</code> | ✓ | |
|
||||
| [external_addresses](variables.tf#L17) | Map of external addresses, keyed by name. | <code title="map(object({ region = string description = optional(string, "Terraform managed.") ipv6 = optional(object({ endpoint_type = string })) labels = optional(map(string), {}) name = optional(string) tier = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [global_addresses](variables.tf#L39) | List of global addresses to create. | <code title="map(object({ description = optional(string, "Terraform managed.") ipv6 = optional(map(string)) # To be left empty for ipv6 name = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [internal_addresses](variables.tf#L49) | Map of internal addresses to create, keyed by name. | <code title="map(object({ region = string subnetwork = string address = optional(string) description = optional(string, "Terraform managed.") ipv6 = optional(map(string)) # To be left empty for ipv6 labels = optional(map(string)) name = optional(string) purpose = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [ipsec_interconnect_addresses](variables.tf#L64) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | <code title="map(object({ region = string address = string network = string description = optional(string, "Terraform managed.") name = optional(string) prefix_length = number }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [psa_addresses](variables.tf#L88) | Map of internal addresses used for Private Service Access. | <code title="map(object({ address = string network = string prefix_length = number description = optional(string, "Terraform managed.") name = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [psc_addresses](variables.tf#L101) | Map of internal addresses used for Private Service Connect. | <code title="map(object({ address = string network = string description = optional(string, "Terraform managed.") name = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [project_id](variables.tf#L84) | Project where the addresses will be created. | <code>string</code> | ✓ | |
|
||||
| [external_addresses](variables.tf#L17) | Map of external addresses, keyed by name. | <code title="map(object({ region = string description = optional(string, "Terraform managed.") ipv6 = optional(object({ endpoint_type = string })) labels = optional(map(string), {}) name = optional(string) subnetwork = optional(string) # for IPv6 tier = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [global_addresses](variables.tf#L40) | List of global addresses to create. | <code title="map(object({ description = optional(string, "Terraform managed.") ipv6 = optional(map(string)) # To be left empty for ipv6 name = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [internal_addresses](variables.tf#L50) | Map of internal addresses to create, keyed by name. | <code title="map(object({ region = string subnetwork = string address = optional(string) description = optional(string, "Terraform managed.") ipv6 = optional(map(string)) # To be left empty for ipv6 labels = optional(map(string)) name = optional(string) purpose = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [ipsec_interconnect_addresses](variables.tf#L65) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | <code title="map(object({ region = string address = string network = string description = optional(string, "Terraform managed.") name = optional(string) prefix_length = number }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [psa_addresses](variables.tf#L89) | Map of internal addresses used for Private Service Access. | <code title="map(object({ address = string network = string prefix_length = number description = optional(string, "Terraform managed.") name = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [psc_addresses](variables.tf#L102) | Map of internal addresses used for Private Service Connect. | <code title="map(object({ address = string network = string description = optional(string, "Terraform managed.") name = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -27,13 +27,14 @@ resource "google_compute_address" "external" {
|
||||
for_each = var.external_addresses
|
||||
project = var.project_id
|
||||
name = coalesce(each.value.name, each.key)
|
||||
description = each.value.description
|
||||
address_type = "EXTERNAL"
|
||||
description = each.value.description
|
||||
ip_version = each.value.ipv6 != null ? "IPV6" : "IPV4"
|
||||
ipv6_endpoint_type = try(each.value.ipv6.endpoint_type, null)
|
||||
labels = each.value.labels
|
||||
network_tier = each.value.tier
|
||||
region = each.value.region
|
||||
labels = each.value.labels
|
||||
subnetwork = each.value.subnetwork
|
||||
}
|
||||
|
||||
resource "google_compute_address" "internal" {
|
||||
@@ -41,14 +42,14 @@ resource "google_compute_address" "internal" {
|
||||
for_each = var.internal_addresses
|
||||
project = var.project_id
|
||||
name = coalesce(each.value.name, each.key)
|
||||
description = each.value.description
|
||||
address = each.value.address
|
||||
address_type = "INTERNAL"
|
||||
description = each.value.description
|
||||
ip_version = each.value.ipv6 != null ? "IPV6" : "IPV4"
|
||||
labels = coalesce(each.value.labels, {})
|
||||
purpose = each.value.purpose
|
||||
region = each.value.region
|
||||
subnetwork = each.value.subnetwork
|
||||
address = each.value.address
|
||||
ip_version = each.value.ipv6 != null ? "IPV6" : "IPV4"
|
||||
purpose = each.value.purpose
|
||||
labels = coalesce(each.value.labels, {})
|
||||
}
|
||||
|
||||
resource "google_compute_global_address" "psc" {
|
||||
|
||||
@@ -22,9 +22,10 @@ variable "external_addresses" {
|
||||
ipv6 = optional(object({
|
||||
endpoint_type = string
|
||||
}))
|
||||
labels = optional(map(string), {})
|
||||
name = optional(string)
|
||||
tier = optional(string)
|
||||
labels = optional(map(string), {})
|
||||
name = optional(string)
|
||||
subnetwork = optional(string) # for IPv6
|
||||
tier = optional(string)
|
||||
}))
|
||||
default = {}
|
||||
validation {
|
||||
|
||||
Reference in New Issue
Block a user