From 5fd3c4972a768295d63285912ea3aa55ede5a27f Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Wed, 26 Jan 2022 11:54:24 -0500 Subject: [PATCH] Add EXTERNAL_MANAGED option to global forwarding rule and add example (#5611) --- mmv1/products/compute/api.yaml | 4 +- mmv1/products/compute/terraform.yaml | 11 +++++ ...al_forwarding_rule_external_managed.tf.erb | 45 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 mmv1/templates/terraform/examples/global_forwarding_rule_external_managed.tf.erb diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index 3a33222f4161..781eb49a105e 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -4264,13 +4264,15 @@ objects: The value of INTERNAL_SELF_MANAGED means that this will be used for Internal Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External Global Load Balancing (HTTP(S) LB, - External TCP/UDP LB, SSL Proxy) + External TCP/UDP LB, SSL Proxy). The value of EXTERNAL_MANAGED means + that this will be used for Global external HTTP(S) load balancers. ([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) only) Note: This field must be set "" if the global address is configured as a purpose of PRIVATE_SERVICE_CONNECT and addressType of INTERNAL. default_value: :EXTERNAL values: - :EXTERNAL + - :EXTERNAL_MANAGED - :INTERNAL_SELF_MANAGED - !ruby/object:Api::Type::Array name: 'metadataFilters' diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 2679f75bc11f..11e06774946b 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -1037,6 +1037,17 @@ overrides: !ruby/object:Overrides::ResourceOverrides ignore_read_extra: - "port_range" - "target" + - !ruby/object:Provider::Terraform::Examples + name: "global_forwarding_rule_external_managed" + min_version: beta + primary_resource_id: "default" + vars: + forwarding_rule_name: "global-rule" + http_proxy_name: "target-proxy" + backend_service_name: "backend" + ignore_read_extra: + - "port_range" + - "target" - !ruby/object:Provider::Terraform::Examples name: "private_service_connect_google_apis" min_version: beta diff --git a/mmv1/templates/terraform/examples/global_forwarding_rule_external_managed.tf.erb b/mmv1/templates/terraform/examples/global_forwarding_rule_external_managed.tf.erb new file mode 100644 index 000000000000..1d38a0ee420b --- /dev/null +++ b/mmv1/templates/terraform/examples/global_forwarding_rule_external_managed.tf.erb @@ -0,0 +1,45 @@ +resource "google_compute_global_forwarding_rule" "default" { + provider = google-beta + name = "<%= ctx[:vars]['forwarding_rule_name'] %>" + target = google_compute_target_http_proxy.default.id + port_range = "80" + load_balancing_scheme = "EXTERNAL_MANAGED" +} + +resource "google_compute_target_http_proxy" "default" { + provider = google-beta + name = "<%= ctx[:vars]['http_proxy_name'] %>" + description = "a description" + url_map = google_compute_url_map.default.id +} + +resource "google_compute_url_map" "default" { + provider = google-beta + name = "url-map-<%= ctx[:vars]['http_proxy_name'] %>" + description = "a description" + default_service = google_compute_backend_service.default.id + + host_rule { + hosts = ["mysite.com"] + path_matcher = "allpaths" + } + + path_matcher { + name = "allpaths" + default_service = google_compute_backend_service.default.id + + path_rule { + paths = ["/*"] + service = google_compute_backend_service.default.id + } + } +} + +resource "google_compute_backend_service" "default" { + provider = google-beta + name = "<%= ctx[:vars]['backend_service_name'] %>" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 + load_balancing_scheme = "EXTERNAL_MANAGED" +}