Fix urlmap in ILB L7 module (#1299)
* port tests to new format * add test to catch error and fix urlmap * boilerplate * boilerplate
This commit is contained in:
parent
bf14d2da23
commit
bc2d9372aa
|
@ -545,9 +545,9 @@ resource "google_compute_region_url_map" "default" {
|
|||
}
|
||||
dynamic "url_redirect" {
|
||||
for_each = (
|
||||
route_rules.value.default_url_redirect == null
|
||||
route_rules.value.url_redirect == null
|
||||
? []
|
||||
: [route_rules.value.default_url_redirect]
|
||||
: [route_rules.value.url_redirect]
|
||||
)
|
||||
content {
|
||||
host_redirect = url_redirect.value.host
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
project_id = "my-project"
|
||||
name = "ilb-l7-test"
|
||||
region = "europe-west1"
|
||||
vpc_config = {
|
||||
network = "projects/my-project/global/networks/default"
|
||||
subnetwork = "projects/my-project/regions/europe-west1/subnetworks/default"
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_region_backend_service: 1
|
||||
google_compute_region_target_http_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -1,38 +0,0 @@
|
|||
/**
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module "test" {
|
||||
source = "../../../../modules/net-ilb-l7"
|
||||
project_id = "my-project"
|
||||
name = "ilb-l7-test"
|
||||
region = "europe-west1"
|
||||
vpc_config = {
|
||||
network = "projects/my-project/global/networks/default"
|
||||
subnetwork = "projects/my-project/regions/europe-west1/subnetworks/default"
|
||||
}
|
||||
address = var.address
|
||||
backend_service_configs = var.backend_service_configs
|
||||
description = var.description
|
||||
group_configs = var.group_configs
|
||||
health_check_configs = var.health_check_configs
|
||||
labels = var.labels
|
||||
neg_configs = var.neg_configs
|
||||
network_tier_premium = var.network_tier_premium
|
||||
ports = var.ports
|
||||
protocol = var.protocol
|
||||
ssl_certificates = var.ssl_certificates
|
||||
urlmap_config = var.urlmap_config
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "custom"
|
||||
}]
|
||||
}
|
||||
}
|
||||
group_configs = {
|
||||
custom = {
|
||||
zone = "europe-west1-b"
|
||||
instances = [
|
||||
"projects/myprj/zones/europe-west1-b/instances/vm-a"
|
||||
]
|
||||
named_ports = { http = 80 }
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
health_checks = ["custom"]
|
||||
}
|
||||
}
|
||||
health_check_configs = {
|
||||
custom = {
|
||||
tcp = {
|
||||
port_specification = "USE_SERVING_PORT"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
health_checks = ["projects/myprj/global/healthChecks/custom"]
|
||||
}
|
||||
}
|
||||
health_check_configs = {}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
protocol = "HTTPS"
|
||||
ssl_certificates = {
|
||||
certificate_ids = [
|
||||
"projects/myprj/regions/europe-west1/sslCertificates/my-cert"
|
||||
]
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "custom"
|
||||
}]
|
||||
}
|
||||
}
|
||||
neg_configs = {
|
||||
custom = {
|
||||
gce = {
|
||||
zone = "europe-west1-b"
|
||||
endpoints = {
|
||||
e-0 = {
|
||||
ip_address = "10.0.0.10"
|
||||
instance = "test-1"
|
||||
port = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
protocol = "HTTPS"
|
||||
ssl_certificates = {
|
||||
create_configs = {
|
||||
default = {
|
||||
certificate = "FOO"
|
||||
private_key = "FOO"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
}
|
||||
video = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig-2"
|
||||
}]
|
||||
}
|
||||
}
|
||||
urlmap_config = {
|
||||
default_service = "default"
|
||||
host_rules = [{
|
||||
hosts = ["*"]
|
||||
path_matcher = "pathmap"
|
||||
}]
|
||||
path_matchers = {
|
||||
pathmap = {
|
||||
default_service = "default"
|
||||
path_rules = [{
|
||||
paths = ["/video", "/video/*"]
|
||||
service = "video"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/**
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
variable "address" {
|
||||
description = "Optional IP address used for the forwarding rule."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "backend_service_configs" {
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "description" {
|
||||
type = string
|
||||
default = "Terraform managed."
|
||||
}
|
||||
|
||||
variable "group_configs" {
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "health_check_configs" {
|
||||
type = any
|
||||
default = {
|
||||
default = {
|
||||
http = {
|
||||
port_specification = "USE_SERVING_PORT"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "neg_configs" {
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "network_tier_premium" {
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "ports" {
|
||||
type = list(string)
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "protocol" {
|
||||
type = string
|
||||
default = "HTTP"
|
||||
}
|
||||
|
||||
variable "ssl_certificates" {
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "urlmap_config" {
|
||||
type = any
|
||||
default = {
|
||||
default_service = "default"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "custom"
|
||||
}]
|
||||
}
|
||||
}
|
||||
group_configs = {
|
||||
custom = {
|
||||
zone = "europe-west1-b"
|
||||
instances = [
|
||||
"projects/myprj/zones/europe-west1-b/instances/vm-a"
|
||||
]
|
||||
named_ports = { http = 80 }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_instance_group: 1
|
||||
google_compute_region_backend_service: 1
|
||||
google_compute_region_target_http_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
health_checks = ["custom"]
|
||||
}
|
||||
}
|
||||
health_check_configs = {
|
||||
custom = {
|
||||
tcp = {
|
||||
port_specification = "USE_SERVING_PORT"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_region_backend_service: 1
|
||||
google_compute_region_target_http_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
health_checks = ["projects/myprj/global/healthChecks/custom"]
|
||||
}
|
||||
}
|
||||
health_check_configs = {}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_region_backend_service: 1
|
||||
google_compute_region_target_http_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
protocol = "HTTPS"
|
||||
ssl_certificates = {
|
||||
certificate_ids = [
|
||||
"projects/myprj/regions/europe-west1/sslCertificates/my-cert"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_region_target_https_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "custom"
|
||||
}]
|
||||
}
|
||||
}
|
||||
neg_configs = {
|
||||
custom = {
|
||||
gce = {
|
||||
zone = "europe-west1-b"
|
||||
endpoints = {
|
||||
e-0 = {
|
||||
ip_address = "10.0.0.10"
|
||||
instance = "test-1"
|
||||
port = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_network_endpoint: 1
|
||||
google_compute_network_endpoint_group: 1
|
||||
google_compute_region_backend_service: 1
|
||||
google_compute_region_target_http_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
protocol = "HTTPS"
|
||||
ssl_certificates = {
|
||||
create_configs = {
|
||||
default = {
|
||||
certificate = "FOO"
|
||||
private_key = "FOO"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_region_ssl_certificate: 1
|
||||
google_compute_region_target_https_proxy: 1
|
||||
google_compute_region_url_map: 1
|
|
@ -1,120 +0,0 @@
|
|||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import collections
|
||||
|
||||
|
||||
def test_defaults(plan_runner):
|
||||
"Test with default values."
|
||||
_, resources = plan_runner(tf_var_file='test.defaults.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_region_backend_service.default': 1,
|
||||
'google_compute_region_target_http_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_groups(plan_runner):
|
||||
"Test groups."
|
||||
_, resources = plan_runner(tf_var_file='test.groups.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_instance_group.default': 1,
|
||||
'google_compute_region_backend_service.default': 1,
|
||||
'google_compute_region_target_http_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_health_checks_external(plan_runner):
|
||||
"Test external health check."
|
||||
_, resources = plan_runner(tf_var_file='test.health-checks-external.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_region_backend_service.default': 1,
|
||||
'google_compute_region_target_http_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_health_checks_custom(plan_runner):
|
||||
"Test custom health check."
|
||||
_, resources = plan_runner(tf_var_file='test.health-checks-custom.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_region_backend_service.default': 1,
|
||||
'google_compute_region_target_http_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_https(plan_runner):
|
||||
"Test HTTPS load balancer."
|
||||
_, resources = plan_runner(tf_var_file='test.https.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_region_target_https_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_negs(plan_runner):
|
||||
"Test negs."
|
||||
_, resources = plan_runner(tf_var_file='test.negs.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_network_endpoint.default': 1,
|
||||
'google_compute_network_endpoint_group.default': 1,
|
||||
'google_compute_region_backend_service.default': 1,
|
||||
'google_compute_region_target_http_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_ssl_certificates(plan_runner):
|
||||
"Test HTTPS load balancer with SSL certificates."
|
||||
_, resources = plan_runner(tf_var_file='test.ssl.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_region_ssl_certificate.default': 1,
|
||||
'google_compute_region_target_https_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
||||
|
||||
|
||||
def test_urlmaps(plan_runner):
|
||||
"Test URL maps."
|
||||
_, resources = plan_runner(tf_var_file='test.urlmaps.tfvars')
|
||||
counts = collections.Counter(f'{r["type"]}.{r["name"]}' for r in resources)
|
||||
assert counts == {
|
||||
'google_compute_forwarding_rule.default': 1,
|
||||
'google_compute_health_check.default': 1,
|
||||
'google_compute_region_backend_service.default': 2,
|
||||
'google_compute_region_target_http_proxy.default': 1,
|
||||
'google_compute_region_url_map.default': 1
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
module: modules/net-ilb-l7
|
||||
common_tfvars:
|
||||
- common.tfvars
|
||||
tests:
|
||||
defaults:
|
||||
groups:
|
||||
health-checks-custom:
|
||||
health-checks-external:
|
||||
https:
|
||||
negs:
|
||||
ssl:
|
||||
urlmaps:
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
backend_service_configs = {
|
||||
default = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig"
|
||||
}]
|
||||
}
|
||||
video = {
|
||||
backends = [{
|
||||
group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig-2"
|
||||
}]
|
||||
}
|
||||
}
|
||||
urlmap_config = {
|
||||
default_service = "default"
|
||||
host_rules = [{
|
||||
hosts = ["*"]
|
||||
path_matcher = "pathmap"
|
||||
}]
|
||||
path_matchers = {
|
||||
pathmap = {
|
||||
default_service = "default"
|
||||
path_rules = [{
|
||||
paths = ["/video", "/video/*"]
|
||||
service = "video"
|
||||
}]
|
||||
route_rules = [{
|
||||
priority = 1
|
||||
service = "default"
|
||||
match_rules = [{
|
||||
ignore_case = true
|
||||
}]
|
||||
url_redirect = {
|
||||
host = "foo.example.org"
|
||||
https = true
|
||||
path = "/foo"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
counts:
|
||||
google_compute_forwarding_rule: 1
|
||||
google_compute_health_check: 1
|
||||
google_compute_region_backend_service: 2
|
||||
google_compute_region_target_http_proxy: 1
|
||||
google_compute_region_url_map: 1
|
Loading…
Reference in New Issue