Skip to content

Commit

Permalink
Add EXTERNAL_MANAGED option to global forwarding rule and add example (
Browse files Browse the repository at this point in the history
…#5611) (#4011)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 26, 2022
1 parent 6d51ab4 commit 525404e
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/5611.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: Added `EXTERNAL_MANAGED` as option for `load_balancing_scheme` in `google_compute_global_forwarding_rule` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,81 @@ resource "google_compute_health_check" "default" {
`, context)
}

func TestAccComputeGlobalForwardingRule_globalForwardingRuleExternalManagedExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeGlobalForwardingRule_globalForwardingRuleExternalManagedExample(context),
},
{
ResourceName: "google_compute_global_forwarding_rule.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"network", "port_range", "target"},
},
},
})
}

func testAccComputeGlobalForwardingRule_globalForwardingRuleExternalManagedExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_global_forwarding_rule" "default" {
provider = google-beta
name = "tf-test-global-rule%{random_suffix}"
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 = "tf-test-target-proxy%{random_suffix}"
description = "a description"
url_map = google_compute_url_map.default.id
}
resource "google_compute_url_map" "default" {
provider = google-beta
name = "url-map-tf-test-target-proxy%{random_suffix}"
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 = "backend%{random_suffix}"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL_MANAGED"
}
`, context)
}

func TestAccComputeGlobalForwardingRule_privateServiceConnectGoogleApisExample(t *testing.T) {
t.Parallel()

Expand Down
60 changes: 58 additions & 2 deletions website/docs/r/compute_global_forwarding_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,61 @@ resource "google_compute_health_check" "default" {
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=global_forwarding_rule_external_managed&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Global Forwarding Rule External Managed


```hcl
resource "google_compute_global_forwarding_rule" "default" {
provider = google-beta
name = "global-rule"
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 = "target-proxy"
description = "a description"
url_map = google_compute_url_map.default.id
}
resource "google_compute_url_map" "default" {
provider = google-beta
name = "url-map-target-proxy"
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 = "backend"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL_MANAGED"
}
```
## Example Usage - Private Service Connect Google Apis


Expand Down Expand Up @@ -974,11 +1029,12 @@ The following arguments are supported:
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 is `EXTERNAL`.
Possible values are `EXTERNAL` and `INTERNAL_SELF_MANAGED`.
Possible values are `EXTERNAL`, `EXTERNAL_MANAGED`, and `INTERNAL_SELF_MANAGED`.

* `metadata_filters` -
(Optional)
Expand Down

0 comments on commit 525404e

Please sign in to comment.