Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end-to-end tests for net-lb-app-ext-regional #1962

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions modules/net-address/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,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&#40;object&#40;&#123;&#10; region &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;object&#40;&#123;&#10; endpoint_type &#61; string&#10; &#125;&#41;&#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#L38) | List of global addresses to create. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#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> |
| [internal_addresses](variables.tf#L48) | 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; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#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#L64) | 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#L88) | 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#L101) | 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> |
| [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&#40;object&#40;&#123;&#10; region &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;object&#40;&#123;&#10; endpoint_type &#61; string&#10; &#125;&#41;&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;, &#123;&#125;&#41;&#10; name &#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> |
| [global_addresses](variables.tf#L39) | List of global addresses to create. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#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> |
| [internal_addresses](variables.tf#L49) | 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; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#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#L65) | 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#L89) | 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#L102) | 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
1 change: 1 addition & 0 deletions modules/net-address/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "google_compute_address" "external" {
address_type = "EXTERNAL"
ip_version = each.value.ipv6 != null ? "IPV6" : "IPV4"
ipv6_endpoint_type = try(each.value.ipv6.endpoint_type, null)
network_tier = each.value.tier
region = each.value.region
labels = each.value.labels
}
Expand Down
1 change: 1 addition & 0 deletions modules/net-address/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ variable "external_addresses" {
}))
labels = optional(map(string), {})
name = optional(string)
tier = optional(string)
}))
default = {}
validation {
Expand Down
81 changes: 42 additions & 39 deletions modules/net-lb-app-ext-regional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ module "glb-0" {
backend_service_configs = {
default = {
backends = [
{ backend = module.compute-mig-b.group.id },
{ backend = module.compute-mig-c.group.id }
{ backend = module.compute-vm-group-b.group.id },
{ backend = module.compute-vm-group-c.group.id }
]
}
}
}
# tftest modules=3 resources=9 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=9 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

### Minimal HTTPS examples
Expand Down Expand Up @@ -89,8 +89,8 @@ module "ralb-0" {
backend_service_configs = {
default = {
backends = [
{ backend = module.compute-mig-b.group.id },
{ backend = module.compute-mig-c.group.id }
{ backend = module.compute-vm-group-b.group.id },
{ backend = module.compute-vm-group-c.group.id }
]
protocol = "HTTP"
}
Expand All @@ -106,7 +106,7 @@ module "ralb-0" {
}
}
}
# tftest modules=3 resources=12 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=12 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

#### HTTPS backends
Expand All @@ -123,8 +123,8 @@ module "ralb-0" {
backend_service_configs = {
default = {
backends = [
{ backend = module.compute-mig-b.group.id },
{ backend = module.compute-mig-c.group.id }
{ backend = module.compute-vm-group-b.group.id },
{ backend = module.compute-vm-group-c.group.id }
]
protocol = "HTTPS"
}
Expand All @@ -146,7 +146,7 @@ module "ralb-0" {
}
}
}
# tftest modules=3 resources=12 fixtures=fixtures/ssl-certificate.tf,fixtures/compute-mig-bc.tf
# tftest modules=3 resources=12 fixtures=fixtures/ssl-certificate.tf,fixtures/compute-vm-group-bc.tf e2e
```

#### HTTP to HTTPS redirect
Expand All @@ -157,8 +157,11 @@ Redirect is implemented via an additional HTTP load balancer with a custom URL m
module "addresses" {
source = "./fabric/modules/net-address"
project_id = var.project_id
global_addresses = {
"ralb-test-0" = {}
external_addresses = {
"ralb-test-0" = {
region = var.region
tier = "STANDARD"
}
}
}

Expand All @@ -169,7 +172,7 @@ module "ralb-test-0-redirect" {
vpc = var.vpc.self_link
region = var.region
address = (
module.addresses.global_addresses["ralb-test-0"].address
module.addresses.external_addresses["ralb-test-0"].id
)
health_check_configs = {}
urlmap_config = {
Expand All @@ -188,12 +191,12 @@ module "ralb-test-0" {
vpc = var.vpc.self_link
region = var.region
address = (
module.addresses.global_addresses["ralb-test-0"].address
module.addresses.external_addresses["ralb-test-0"].id
)
backend_service_configs = {
default = {
backends = [
{ backend = module.compute-mig-b.group.id },
{ backend = module.compute-vm-group-b.group.id },
]
protocol = "HTTP"
}
Expand All @@ -209,7 +212,7 @@ module "ralb-test-0" {
}
}

# tftest modules=5 resources=16 fixtures=fixtures/ssl-certificate.tf,fixtures/compute-mig-bc.tf
# tftest modules=5 resources=16 fixtures=fixtures/ssl-certificate.tf,fixtures/compute-vm-group-bc.tf e2e
```

### Health Checks
Expand All @@ -230,7 +233,7 @@ module "ralb-0" {
backend_service_configs = {
default = {
backends = [{
backend = module.compute-mig-b.group.id
backend = module.compute-vm-group-b.group.id
}]
# no need to reference the hc explicitly when using the `default` key
# health_checks = ["default"]
Expand All @@ -242,7 +245,7 @@ module "ralb-0" {
}
}
}
# tftest modules=3 resources=9 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=9 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

To leverage existing health checks without having the module create them, simply pass their self links to backend services and set the `health_check_configs` variable to an empty map:
Expand All @@ -257,14 +260,14 @@ module "ralb-0" {
backend_service_configs = {
default = {
backends = [{
backend = module.compute-mig-b.group.id
backend = module.compute-vm-group-b.group.id
}]
health_checks = ["projects/${var.project_id}/global/healthChecks/custom"]
health_checks = ["projects/${var.project_id}/regions/${var.region}/healthChecks/custom"]
}
}
health_check_configs = {}
}
# tftest modules=3 resources=8 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=8 fixtures=fixtures/compute-vm-group-bc.tf
```

### Backend Types and Management
Expand All @@ -291,13 +294,13 @@ module "ralb-0" {
default-b = {
zone = "${var.region}-b"
instances = [
module.compute-mig-b.id
module.compute-vm-group-b.id
]
named_ports = { http = 80 }
}
}
}
# tftest modules=3 resources=10 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=10 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

#### Managed Instance Groups
Expand Down Expand Up @@ -361,7 +364,7 @@ module "ralb-0" {
}
}
}
# tftest modules=3 resources=8
# tftest modules=3 resources=8 e2e
```

#### Zonal NEG creation
Expand Down Expand Up @@ -391,21 +394,21 @@ module "ralb-0" {
neg_configs = {
neg-0 = {
gce = {
network = "projects/myprj-host/global/networks/svpc"
subnetwork = "projects/myprj-host/regions/europe-west8/subnetworks/gce"
network = var.vpc.self_link
subnetwork = var.subnet.self_link
zone = "${var.region}-b"
endpoints = {
e-0 = {
instance = "my-ig-b"
ip_address = module.compute-mig-b.internal_ip
ip_address = module.compute-vm-group-b.internal_ip
port = 80
}
}
}
}
}
}
# tftest modules=3 resources=11 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=11 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

#### Hybrid NEG creation
Expand Down Expand Up @@ -433,7 +436,7 @@ module "ralb-0" {
neg_configs = {
neg-0 = {
hybrid = {
network = "projects/myprj-host/global/networks/svpc"
network = var.vpc.self_link
zone = "${var.region}-b"
endpoints = {
e-0 = {
Expand All @@ -445,7 +448,7 @@ module "ralb-0" {
}
}
}
# tftest modules=1 resources=7
# tftest modules=1 resources=7 e2e
```

#### Private Service Connect NEG creation
Expand Down Expand Up @@ -476,7 +479,7 @@ module "ralb-0" {
}
}
}
# tftest modules=1 resources=5
# tftest modules=1 resources=5 e2e
```

#### Serverless NEG creation
Expand Down Expand Up @@ -511,7 +514,7 @@ module "ralb-0" {
}
}
}
# tftest modules=1 resources=5
# tftest modules=1 resources=5 e2e
```

### URL Map
Expand All @@ -530,12 +533,12 @@ module "ralb-0" {
backend_service_configs = {
default = {
backends = [{
backend = module.compute-mig-b.group.id
backend = module.compute-vm-group-b.group.id
}]
}
other = {
backends = [{
backend = module.compute-mig-c.group.id
backend = module.compute-vm-group-c.group.id
}]
}
}
Expand All @@ -557,7 +560,7 @@ module "ralb-0" {
}
}

# tftest modules=3 resources=10 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=10 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

### Complex example
Expand Down Expand Up @@ -599,14 +602,14 @@ module "ralb-0" {
group-zone-b = {
zone = "${var.region}-b"
instances = [
module.compute-mig-b.id
module.compute-vm-group-b.id
]
named_ports = { http = 80 }
}
group-zone-c = {
zone = "${var.region}-c"
instances = [
module.compute-mig-c.id
module.compute-vm-group-c.id
]
named_ports = { http = 80 }
}
Expand All @@ -633,7 +636,7 @@ module "ralb-0" {
endpoints = {
e-0 = {
instance = "my-ig-c"
ip_address = module.compute-mig-c.internal_ip
ip_address = module.compute-vm-group-c.internal_ip
port = 80
}
}
Expand Down Expand Up @@ -687,7 +690,7 @@ module "ralb-0" {
}
}
}
# tftest modules=3 resources=18 fixtures=fixtures/compute-mig-bc.tf
# tftest modules=3 resources=18 fixtures=fixtures/compute-vm-group-bc.tf e2e
```

<!-- TFDOC OPTS files:1 -->
Expand Down Expand Up @@ -745,6 +748,6 @@ module "ralb-0" {

## Fixtures

- [compute-mig-bc.tf](../../tests/fixtures/compute-mig-bc.tf)
- [compute-vm-group-bc.tf](../../tests/fixtures/compute-vm-group-bc.tf)
- [ssl-certificate.tf](../../tests/fixtures/ssl-certificate.tf)
<!-- END TFDOC -->
Loading
Loading