Skip to content

Commit

Permalink
net-address: allow users to optionally specify address names (#1795)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaPrete authored Oct 23, 2023
1 parent 1ed48b5 commit f54b4f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
14 changes: 7 additions & 7 deletions modules/net-address/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ module "addresses" {

| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [project_id](variables.tf#L65) | 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&#40;object&#40;&#123;&#10; region &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [global_addresses](variables.tf#L27) | List of global addresses to create. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [internal_addresses](variables.tf#L33) | Map of internal addresses to create, keyed by name. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; subnetwork &#61; string&#10; address &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; purpose &#61; optional&#40;string&#41;&#10; tier &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [ipsec_interconnect_addresses](variables.tf#L47) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; prefix_length &#61; number&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psa_addresses](variables.tf#L70) | Map of internal addresses used for Private Service Access. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; prefix_length &#61; number&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psc_addresses](variables.tf#L81) | Map of internal addresses used for Private Service Connect. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [project_id](variables.tf#L68) | 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&#40;object&#40;&#123;&#10; region &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;, &#123;&#125;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [global_addresses](variables.tf#L28) | List of global addresses to create. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [internal_addresses](variables.tf#L34) | Map of internal addresses to create, keyed by name. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; subnetwork &#61; string&#10; address &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; name &#61; optional&#40;string&#41;&#10; purpose &#61; optional&#40;string&#41;&#10; tier &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [ipsec_interconnect_addresses](variables.tf#L49) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10; prefix_length &#61; number&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psa_addresses](variables.tf#L73) | Map of internal addresses used for Private Service Access. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; prefix_length &#61; number&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#10;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psc_addresses](variables.tf#L86) | Map of internal addresses used for Private Service Connect. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |

## Outputs

Expand Down
10 changes: 5 additions & 5 deletions modules/net-address/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "google_compute_address" "external" {
provider = google-beta
for_each = var.external_addresses
project = var.project_id
name = each.key
name = coalesce(each.value.name, each.key)
description = each.value.description
address_type = "EXTERNAL"
region = each.value.region
Expand All @@ -35,7 +35,7 @@ resource "google_compute_address" "internal" {
provider = google-beta
for_each = var.internal_addresses
project = var.project_id
name = each.key
name = coalesce(each.value.name, each.key)
description = each.value.description
address_type = "INTERNAL"
region = each.value.region
Expand All @@ -49,7 +49,7 @@ resource "google_compute_address" "internal" {
resource "google_compute_global_address" "psc" {
for_each = var.psc_addresses
project = var.project_id
name = each.key
name = coalesce(each.value.name, each.key)
description = each.value.description
address = try(each.value.address, null)
address_type = "INTERNAL"
Expand All @@ -61,7 +61,7 @@ resource "google_compute_global_address" "psc" {
resource "google_compute_global_address" "psa" {
for_each = var.psa_addresses
project = var.project_id
name = each.key
name = coalesce(each.value.name, each.key)
description = each.value.description
address = each.value.address
address_type = "INTERNAL"
Expand All @@ -74,7 +74,7 @@ resource "google_compute_global_address" "psa" {
resource "google_compute_address" "ipsec_interconnect" {
for_each = var.ipsec_interconnect_addresses
project = var.project_id
name = each.key
name = coalesce(each.value.name, each.key)
description = each.value.description
address = each.value.address
address_type = "INTERNAL"
Expand Down
8 changes: 7 additions & 1 deletion modules/net-address/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ variable "external_addresses" {
region = string
description = optional(string, "Terraform managed.")
labels = optional(map(string), {})
name = optional(string)
}))
default = {}
}
Expand All @@ -38,6 +39,7 @@ variable "internal_addresses" {
address = optional(string)
description = optional(string, "Terraform managed.")
labels = optional(map(string))
name = optional(string)
purpose = optional(string)
tier = optional(string)
}))
Expand All @@ -51,6 +53,7 @@ variable "ipsec_interconnect_addresses" {
address = string
network = string
description = optional(string, "Terraform managed.")
name = optional(string)
prefix_length = number
}))
default = {}
Expand All @@ -72,8 +75,10 @@ variable "psa_addresses" {
type = map(object({
address = string
network = string
description = optional(string, "Terraform managed.")
prefix_length = number
description = optional(string, "Terraform managed.")
name = optional(string)

}))
default = {}
}
Expand All @@ -84,6 +89,7 @@ variable "psc_addresses" {
address = string
network = string
description = optional(string, "Terraform managed.")
name = optional(string)
}))
default = {}
}

0 comments on commit f54b4f8

Please sign in to comment.