fixed tests
This commit is contained in:
parent
e762e93677
commit
87e82244af
|
@ -23,19 +23,19 @@ At the moment this module doesn't support the following use cases:
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "gcve-pc" {
|
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 = "europe-west8-a"
|
zone = "europe-west8-a"
|
||||||
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-gcve-01/global/networks/default",
|
network_self_link = "projects/test-prj-gcve-01/global/networks/default"
|
||||||
peering_name = "servicenetworking-googleapis-com"
|
tenant_host_project = "g39a814990532d10ap-tp"
|
||||||
type = "PRIVATE_SERVICE_ACCESS",
|
type = "PRIVATE_SERVICE_ACCESS"
|
||||||
routing_mode = "REGIONAL"
|
routing_mode = "REGIONAL"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ module "gcve-pc" {
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "gcve-pc" {
|
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 = "europe-west8-a"
|
zone = "europe-west8-a"
|
||||||
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"
|
||||||
|
@ -59,11 +59,11 @@ module "gcve-pc" {
|
||||||
|
|
||||||
private_connections = {
|
private_connections = {
|
||||||
transit-conn1 = {
|
transit-conn1 = {
|
||||||
name = "transit-conn1",
|
name = "transit-conn1"
|
||||||
network_self_link = "projects/test-prj-gcve-01/global/networks/default",
|
network_self_link = "projects/test-prj-gcve-01/global/networks/default"
|
||||||
peering_name = "servicenetworking-googleapis-com"
|
tenant_host_project = "g39a814990532d10ap-tp"
|
||||||
type = "PRIVATE_SERVICE_ACCESS",
|
type = "PRIVATE_SERVICE_ACCESS"
|
||||||
routing_mode = "REGIONAL"
|
routing_mode = "REGIONAL"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,13 +76,13 @@ module "gcve-pc" {
|
||||||
|---|---|:---:|:---:|:---:|
|
|---|---|:---:|:---:|:---:|
|
||||||
| [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#L43) | Private cloud name. | <code>string</code> | ✓ | |
|
| [name](variables.tf#L43) | Private cloud name. | <code>string</code> | ✓ | |
|
||||||
| [project_id](variables.tf#L76) | Project id. | <code>string</code> | ✓ | |
|
| [project_id](variables.tf#L85) | Project id. | <code>string</code> | ✓ | |
|
||||||
| [zone](variables.tf#L93) | Private cloud zone. | <code>string</code> | ✓ | |
|
| [zone](variables.tf#L102) | Private cloud zone. | <code>string</code> | ✓ | |
|
||||||
| [description](variables.tf#L17) | Private cloud description. | <code>string</code> | | <code>"Terraform-managed."</code> |
|
| [description](variables.tf#L17) | Private cloud description. | <code>string</code> | | <code>"Terraform-managed."</code> |
|
||||||
| [management_cluster_config](variables.tf#L28) | Management cluster configuration. | <code title="object({ node_type_id = string node_count = number, custom_core_count = number })">object({…})</code> | | <code title="{ node_type_id = "standard-72", node_count = 3, custom_core_count = null }">{…}</code> |
|
| [management_cluster_config](variables.tf#L28) | Management cluster configuration. | <code title="object({ node_type_id = string node_count = number, custom_core_count = number })">object({…})</code> | | <code title="{ node_type_id = "standard-72", node_count = 3, custom_core_count = null }">{…}</code> |
|
||||||
| [private_connections](variables.tf#L48) | VMWare private connections configuration. It is used to create the gcloud command printed as output. | <code title="map(object({ name = string network_self_link = string peering_name = string description = optional(string, "Terraform-managed.") type = optional(string, "PRIVATE_SERVICE_ACCESS") routing_mode = optional(string, "REGIONAL") }))">map(object({…}))</code> | | <code>{}</code> |
|
| [private_connections](variables.tf#L48) | VMWare private connections configuration. It is used to create the gcloud command printed as output. | <code title="map(object({ name = string network_self_link = string peering_name = optional(string) tenant_host_project = optional(string) description = optional(string, "Terraform-managed.") type = optional(string, "PRIVATE_SERVICE_ACCESS") routing_mode = optional(string, "REGIONAL") }))">map(object({…}))</code> | | <code>{}</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_create](variables.tf#L90) | 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#L87) | VMware Engine network description. | <code>string</code> | | <code>"Terraform-managed."</code> |
|
| [vmw_network_description](variables.tf#L96) | VMware Engine network description. | <code>string</code> | | <code>"Terraform-managed."</code> |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
@ -96,5 +96,6 @@ module "gcve-pc" {
|
||||||
| [private-cloud](outputs.tf#L42) | The private cloud resource | |
|
| [private-cloud](outputs.tf#L42) | The private cloud resource | |
|
||||||
| [private_connections_setup](outputs.tf#L47) | 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#L63) | Details about the state of the private cloud | |
|
| [state](outputs.tf#L63) | Details about the state of the private cloud | |
|
||||||
|
| [test](outputs.tf#L73) | | |
|
||||||
| [vcenter](outputs.tf#L68) | Details about a vCenter Server management appliance. | |
|
| [vcenter](outputs.tf#L68) | Details about a vCenter Server management appliance. | |
|
||||||
<!-- END TFDOC -->
|
<!-- END TFDOC -->
|
||||||
|
|
|
@ -21,9 +21,10 @@ locals {
|
||||||
? try(google_vmwareengine_network.private-cloud-network.0, null)
|
? try(google_vmwareengine_network.private-cloud-network.0, null)
|
||||||
: try(data.google_vmwareengine_network.private-cloud-network.0, null)
|
: try(data.google_vmwareengine_network.private-cloud-network.0, null)
|
||||||
)
|
)
|
||||||
psa_peering = {
|
tenant_host_project = {
|
||||||
for k, v in data.google_compute_network_peering.psa_peering :
|
for k, v in var.private_connections : k => v.tenant_host_project == null
|
||||||
k => regex("(.*)/projects/([a-z0-9-]*)/(.*)", "${v.peer_network}")[1]
|
? regex("(.*)/projects/([a-z0-9-]*)/(.*)", "${data.google_compute_network_peering.psa_peering[k].peer_network}")[1]
|
||||||
|
: v.tenant_host_project
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +36,8 @@ 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 = { for k, v in var.private_connections : k => v if v.tenant_host_project == null }
|
||||||
name = each.value.peering_name
|
name = each.value.peering_name
|
||||||
network = each.value.network_self_link
|
network = each.value.network_self_link
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ output "private_connections_setup" {
|
||||||
--vmware-engine-network=${local.region}-default \
|
--vmware-engine-network=${local.region}-default \
|
||||||
--description="${v.description}" \
|
--description="${v.description}" \
|
||||||
--routing-mode=${v.routing_mode} \
|
--routing-mode=${v.routing_mode} \
|
||||||
--service-project=${local.psa_peering[k]} \
|
--service-project=${local.tenant_host_project[k]} \
|
||||||
--type=${v.type}
|
--type=${v.type}
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,15 +48,24 @@ variable "name" {
|
||||||
variable "private_connections" {
|
variable "private_connections" {
|
||||||
description = "VMWare private connections configuration. It is used to create the gcloud command printed as output."
|
description = "VMWare private connections configuration. It is used to create the gcloud command printed as output."
|
||||||
type = map(object({
|
type = map(object({
|
||||||
name = string
|
name = string
|
||||||
network_self_link = string
|
network_self_link = string
|
||||||
peering_name = string
|
peering_name = optional(string)
|
||||||
description = optional(string, "Terraform-managed.")
|
tenant_host_project = optional(string)
|
||||||
type = optional(string, "PRIVATE_SERVICE_ACCESS")
|
description = optional(string, "Terraform-managed.")
|
||||||
routing_mode = optional(string, "REGIONAL")
|
type = optional(string, "PRIVATE_SERVICE_ACCESS")
|
||||||
|
routing_mode = optional(string, "REGIONAL")
|
||||||
}))
|
}))
|
||||||
default = {}
|
default = {}
|
||||||
nullable = false
|
nullable = false
|
||||||
|
validation {
|
||||||
|
condition = alltrue([
|
||||||
|
for k, v in var.private_connections :
|
||||||
|
(v.peering_name != null) != (v.tenant_host_project != null)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
error_message = "Both peering_name and tenant_host_project variables have been set. Only one variable is allowed."
|
||||||
|
}
|
||||||
validation {
|
validation {
|
||||||
condition = alltrue([
|
condition = alltrue([
|
||||||
for r in var.private_connections :
|
for r in var.private_connections :
|
||||||
|
|
Loading…
Reference in New Issue