fixed variable name and regex

This commit is contained in:
eliamaldini 2023-08-18 11:20:27 +02:00
parent 5a298780c1
commit d568408331
4 changed files with 40 additions and 33 deletions

View File

@ -26,13 +26,13 @@ module "gcve-pc" {
source = "./fabric/modules/gcve-private-cloud" source = "./fabric/modules/gcve-private-cloud"
name = "gcve-pc" name = "gcve-pc"
project_id = "gcve-test-project" project_id = "gcve-test-project"
zone = "asia-southeast1-a" zone = "europe-west8-a"
management_cidr = "192.168.0.0/24" cidr = "192.168.0.0/24"
private_connections = { private_connections = {
transit-conn1 = { transit-conn1 = {
name = "transit-conn1", name = "transit-conn1",
network_self_link = "projects/test-prj-elia-01/global/networks/default", network_self_link = "projects/test-prj-gcve-01/global/networks/default",
peering_name = "servicenetworking-googleapis-com" peering_name = "servicenetworking-googleapis-com"
type = "PRIVATE_SERVICE_ACCESS", type = "PRIVATE_SERVICE_ACCESS",
routing_mode = "REGIONAL" routing_mode = "REGIONAL"
@ -48,8 +48,8 @@ module "gcve-pc" {
source = "./fabric/modules/gcve-private-cloud" source = "./fabric/modules/gcve-private-cloud"
name = "gcve-pc" name = "gcve-pc"
project_id = "gcve-test-project" project_id = "gcve-test-project"
zone = "asia-southeast1-a" zone = "europe-west8-a"
management_cidr = "192.168.0.0/24" cidr = "192.168.0.0/24"
management_cluster_config = { management_cluster_config = {
node_type_id = "standard-72" node_type_id = "standard-72"
@ -60,7 +60,7 @@ module "gcve-pc" {
private_connections = { private_connections = {
transit-conn1 = { transit-conn1 = {
name = "transit-conn1", name = "transit-conn1",
network_self_link = "projects/test-prj-elia-01/global/networks/default", network_self_link = "projects/test-prj-gcve-01/global/networks/default",
peering_name = "servicenetworking-googleapis-com" peering_name = "servicenetworking-googleapis-com"
type = "PRIVATE_SERVICE_ACCESS", type = "PRIVATE_SERVICE_ACCESS",
routing_mode = "REGIONAL" routing_mode = "REGIONAL"
@ -74,15 +74,15 @@ module "gcve-pc" {
| name | description | type | required | default | | name | description | type | required | default |
|---|---|:---:|:---:|:---:| |---|---|:---:|:---:|:---:|
| [management_cidr](variables.tf#L23) | vSphere/vSAN subnets CIDR range. To undersatnd the limits, please refer to [GCVE network requirements](https://cloud.google.com/vmware-engine/docs/quickstart-networking-requirements). | <code>string</code> | ✓ | | | [cidr](variables.tf#L23) | vSphere/vSAN subnets CIDR range. To undersatnd the limits, please refer to [GCVE network requirements](https://cloud.google.com/vmware-engine/docs/quickstart-networking-requirements). | <code>string</code> | ✓ | |
| [name](variables.tf#L42) | Private cloud name. | <code>string</code> | ✓ | | | [name](variables.tf#L43) | Private cloud name. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L74) | Project id. | <code>string</code> | ✓ | | | [project_id](variables.tf#L76) | Project id. | <code>string</code> | ✓ | |
| [zone](variables.tf#L91) | Private cloud zone. | <code>string</code> | ✓ | | | [zone](variables.tf#L93) | Private cloud zone. | <code>string</code> | ✓ | |
| [description](variables.tf#L17) | Private cloud description. | <code>string</code> | | <code>&#34;Terraform-managed.&#34;</code> | | [description](variables.tf#L17) | Private cloud description. | <code>string</code> | | <code>&#34;Terraform-managed.&#34;</code> |
| [management_cluster_config](variables.tf#L28) | Management cluster configuration. | <code title="object&#40;&#123;&#10; node_type_id &#61; string&#10; node_count &#61; number,&#10; custom_core_count &#61; number&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; node_type_id &#61; &#34;standard-72&#34;,&#10; node_count &#61; 3,&#10; custom_core_count &#61; null&#10;&#125;">&#123;&#8230;&#125;</code> | | [management_cluster_config](variables.tf#L28) | Management cluster configuration. | <code title="object&#40;&#123;&#10; node_type_id &#61; string&#10; node_count &#61; number,&#10; custom_core_count &#61; number&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; node_type_id &#61; &#34;standard-72&#34;,&#10; node_count &#61; 3,&#10; custom_core_count &#61; null&#10;&#125;">&#123;&#8230;&#125;</code> |
| [private_connections](variables.tf#L47) | VMWare private connections configuration. It is used to create the gcloud command printed as output. | <code title="map&#40;object&#40;&#123;&#10; name &#61; string&#10; network_self_link &#61; string&#10; peering_name &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform-managed.&#34;&#41;&#10; type &#61; optional&#40;string, &#34;REGIONAL&#34;&#41;&#10; routing_mode &#61; optional&#40;string, &#34;PRIVATE_SERVICE_ACCESS&#34;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | | [private_connections](variables.tf#L48) | VMWare private connections configuration. It is used to create the gcloud command printed as output. | <code title="map&#40;object&#40;&#123;&#10; name &#61; string&#10; network_self_link &#61; string&#10; peering_name &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform-managed.&#34;&#41;&#10; type &#61; optional&#40;string, &#34;PRIVATE_SERVICE_ACCESS&#34;&#41;&#10; routing_mode &#61; optional&#40;string, &#34;REGIONAL&#34;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [vmw_network_create](variables.tf#L79) | Create the VMware Engine network. When set to false, it uses a data source to reference an existing VMware Engine network. | <code>bool</code> | | <code>true</code> | | [vmw_network_create](variables.tf#L81) | Create the VMware Engine network. When set to false, it uses a data source to reference an existing VMware Engine network. | <code>bool</code> | | <code>true</code> |
| [vmw_network_description](variables.tf#L85) | VMware Engine network description. | <code>string</code> | | <code>&#34;Terraform-managed.&#34;</code> | | [vmw_network_description](variables.tf#L87) | VMware Engine network description. | <code>string</code> | | <code>&#34;Terraform-managed.&#34;</code> |
## Outputs ## Outputs
@ -94,7 +94,7 @@ module "gcve-pc" {
| [network_config](outputs.tf#L32) | Details about the network configuration of the private cloud | | | [network_config](outputs.tf#L32) | Details about the network configuration of the private cloud | |
| [nsx](outputs.tf#L37) | Details about a NSX Manager appliance. | | | [nsx](outputs.tf#L37) | Details about a NSX Manager appliance. | |
| [private-cloud](outputs.tf#L42) | The private cloud resource | | | [private-cloud](outputs.tf#L42) | The private cloud resource | |
| [private_connections_setup](outputs.tf#L57) | Cloud SDK commands for the private connections manual setup. | | | [private_connections_setup](outputs.tf#L47) | Cloud SDK commands for the private connections manual setup. | |
| [state](outputs.tf#L52) | Details about the state of the private cloud | | | [state](outputs.tf#L63) | Details about the state of the private cloud | |
| [vcenter](outputs.tf#L47) | Details about a vCenter Server management appliance. | | | [vcenter](outputs.tf#L68) | Details about a vCenter Server management appliance. | |
<!-- END TFDOC --> <!-- END TFDOC -->

View File

@ -15,7 +15,7 @@
*/ */
locals { locals {
region = join("-", slice(split("-", "${var.zone}"), 0, 2)) region = regex("([a-z]*-[a-z]*[0-9]{1,2})-([a-z])", var.zone)[0]
vmw_network = ( vmw_network = (
var.vmw_network_create var.vmw_network_create
? try(google_vmwareengine_network.private-cloud-network.0, null) ? try(google_vmwareengine_network.private-cloud-network.0, null)
@ -23,7 +23,7 @@ locals {
) )
psa_peering = { psa_peering = {
for k, v in data.google_compute_network_peering.psa_peering : for k, v in data.google_compute_network_peering.psa_peering :
k => slice(split("/", "${v.peer_network}"), 6, 7)[0] k => regex("(.*)/projects/([a-z0-9-]*)/(.*)", "${v.peer_network}")[1]
} }
} }
@ -35,6 +35,7 @@ data "google_vmwareengine_network" "private-cloud-network" {
location = local.region location = local.region
} }
#TO REMOVE?
data "google_compute_network_peering" "psa_peering" { data "google_compute_network_peering" "psa_peering" {
for_each = var.private_connections for_each = var.private_connections
@ -50,7 +51,7 @@ resource "google_vmwareengine_private_cloud" "private-cloud" {
description = var.description description = var.description
network_config { network_config {
management_cidr = var.management_cidr management_cidr = var.cidr
vmware_engine_network = local.vmw_network.id vmware_engine_network = local.vmw_network.id
} }

View File

@ -44,16 +44,6 @@ output "private-cloud" {
value = google_vmwareengine_private_cloud.private-cloud value = google_vmwareengine_private_cloud.private-cloud
} }
output "vcenter" {
description = "Details about a vCenter Server management appliance."
value = google_vmwareengine_private_cloud.private-cloud.vcenter
}
output "state" {
description = "Details about the state of the private cloud"
value = google_vmwareengine_private_cloud.private-cloud.state
}
output "private_connections_setup" { output "private_connections_setup" {
description = "Cloud SDK commands for the private connections manual setup." description = "Cloud SDK commands for the private connections manual setup."
value = { value = {
@ -69,3 +59,17 @@ output "private_connections_setup" {
EOT EOT
} }
} }
output "state" {
description = "Details about the state of the private cloud"
value = google_vmwareengine_private_cloud.private-cloud.state
}
output "vcenter" {
description = "Details about a vCenter Server management appliance."
value = google_vmwareengine_private_cloud.private-cloud.vcenter
}
output "test" {
value = data.google_compute_network_peering.psa_peering
}

View File

@ -20,7 +20,7 @@ variable "description" {
default = "Terraform-managed." default = "Terraform-managed."
} }
variable "management_cidr" { variable "cidr" {
description = "vSphere/vSAN subnets CIDR range. To undersatnd the limits, please refer to [GCVE network requirements](https://cloud.google.com/vmware-engine/docs/quickstart-networking-requirements)." description = "vSphere/vSAN subnets CIDR range. To undersatnd the limits, please refer to [GCVE network requirements](https://cloud.google.com/vmware-engine/docs/quickstart-networking-requirements)."
type = string type = string
} }
@ -37,6 +37,7 @@ variable "management_cluster_config" {
node_count = 3, node_count = 3,
custom_core_count = null custom_core_count = null
} }
nullable = false
} }
variable "name" { variable "name" {
@ -51,10 +52,11 @@ variable "private_connections" {
network_self_link = string network_self_link = string
peering_name = string peering_name = string
description = optional(string, "Terraform-managed.") description = optional(string, "Terraform-managed.")
type = optional(string, "REGIONAL") type = optional(string, "PRIVATE_SERVICE_ACCESS")
routing_mode = optional(string, "PRIVATE_SERVICE_ACCESS") routing_mode = optional(string, "REGIONAL")
})) }))
default = {} default = {}
nullable = false
validation { validation {
condition = alltrue([ condition = alltrue([
for r in var.private_connections : for r in var.private_connections :