Skip to content

Commit

Permalink
Add support for INTERNAL_SELF_MANAGED backend service and global forw…
Browse files Browse the repository at this point in the history
…arding rule
  • Loading branch information
slevenick committed May 24, 2019
1 parent 9025e1c commit 707c88c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
8 changes: 6 additions & 2 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ objects:
The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource
for health checking this BackendService. Currently at most one health
check can be specified, and a health check is required.
For internal load balancing, a URL to a HealthCheck resource must be specified instead.
- !ruby/object:Api::Type::Integer
name: 'id'
description: 'The unique identifier for the resource.'
Expand Down Expand Up @@ -839,14 +841,15 @@ objects:
description: |
Indicates whether the backend service will be used with internal or
external load balancing. A backend service created for one type of
load balancing cannot be used with the other. Must be `EXTERNAL` for
a global backend service. Defaults to `EXTERNAL`.
load balancing cannot be used with the other. Must be `EXTERNAL` or
`INTERNAL_SELF_MANAGED` for a global backend service. Defaults to `EXTERNAL`.
default_value: :EXTERNAL
# If you're modifying this value, it probably means Global ILB is now
# an option. If that's the case, all of the documentation is based on
# this resource supporting external load balancing only.
values:
- :EXTERNAL
- :INTERNAL_SELF_MANAGED
- !ruby/object:Api::Type::String
name: 'name'
required: true
Expand Down Expand Up @@ -2317,6 +2320,7 @@ objects:
NOTE: Currently global forwarding rules cannot be used for INTERNAL
load balancing.
default_value: :EXTERNAL
values:
- :INTERNAL_SELF_MANAGED
- :EXTERNAL
Expand Down
12 changes: 9 additions & 3 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides
forwarding_rule_name: "global-rule"
http_proxy_name: "target-proxy"
backend_service_name: "backend"
- !ruby/object:Provider::Terraform::Examples
name: "global_forwarding_rule_internal"
min_version: beta
primary_resource_id: "default"
vars:
forwarding_rule_name: "global-rule"
http_proxy_name: "target-proxy"
backend_service_name: "backend"
properties:
creationTimestamp: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
Expand All @@ -542,10 +550,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
IPProtocol: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: 'caseDiffSuppress'
default_from_api: true
loadBalancingScheme: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
network: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
default_from_api: true
portRange: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: 'portRangeDiffSuppress'
target: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
resource "google_compute_global_forwarding_rule" "default" {
provider = "google-beta"
name = "<%= ctx[:vars]['forwarding_rule_name'] %>"
target = "${google_compute_target_http_proxy.default.self_link}"
port_range = "80"
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
ip_address = "0.0.0.0"
}

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.self_link}"
}

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.self_link}"

host_rule {
hosts = ["mysite.com"]
path_matcher = "allpaths"
}

path_matcher {
name = "allpaths"
default_service = "${google_compute_backend_service.default.self_link}"

path_rule {
paths = ["/*"]
service = "${google_compute_backend_service.default.self_link}"
}
}
}

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 = "INTERNAL_SELF_MANAGED"

health_checks = ["${google_compute_health_check.default.self_link}"]
}

resource "google_compute_health_check" "default" {
provider = "google-beta"
name = "check-<%= ctx[:vars]['backend_service_name'] %>"
check_interval_sec = 1
timeout_sec = 1

tcp_health_check {
port = "80"
}
}

0 comments on commit 707c88c

Please sign in to comment.