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

Unable to create External regional TCP Load balancer #4936

Closed
ArnauFauquer opened this issue Nov 18, 2019 · 5 comments
Closed

Unable to create External regional TCP Load balancer #4936

ArnauFauquer opened this issue Nov 18, 2019 · 5 comments

Comments

@ArnauFauquer
Copy link

ArnauFauquer commented Nov 18, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

I'm unable to create an external regional TCP Load balancer

New or Affected Resource(s)

google/compute_region_backend_service

Potential Terraform Configuration

resource "google_compute_region_backend_service" "lb-backend" {
  health_checks = [google_compute_health_check.autohealing.self_link]
  name = var.project
  region = var.region
  load_balancing_scheme = "EXTERNAL"

resource "google_compute_health_check" "autohealing" {
  name = "autohealing-health-check"
  http_health_check {
    port = "80"
    host = "/"
  }
}
}

References

https://www.terraform.io/docs/providers/google/r/compute_region_backend_service.html

@ghost ghost added the enhancement label Nov 18, 2019
@migibert
Copy link
Contributor

I think this is not a good resource to create external load balancers;
As stated in the documentation:

load_balancing_scheme - (Optional) Indicates what kind of load balancing this regional backend service will be used for. A backend service created for one type of load balancing cannot be used with the other(s). Must be INTERNAL or INTERNAL_MANAGED. Defaults to INTERNAL.

I used to use the following resources to manage external TCP load balancers:

  • google_compute_instance_group_manager
  • google_compute_global_forwarding_rule
  • google_compute_target_http_proxy
  • google_compute_url_map

Complete example:

resource "google_compute_global_address" "global-address" {
  provider = "google-beta"
  name     = "${var.name}"
  labels   = "${var.labels}"

  lifecycle {
    prevent_destroy = true
  }
}

resource "google_compute_global_forwarding_rule" "https-forwarding-rule" {
  provider    = "google-beta"
  name        = "${var.name}-https"
  target      = "${google_compute_target_https_proxy.https-proxy.self_link}"
  ip_address  = "${google_compute_global_address.global-address.address}"
  ip_protocol = "TCP"
  port_range  = "443"
  labels      = "${var.labels}"
}

resource "google_compute_global_forwarding_rule" "http-forwarding-rule" {
  provider    = "google-beta"
  name        = "${var.name}-http"
  target      = "${google_compute_target_http_proxy.http-proxy.self_link}"
  ip_address  = "${google_compute_global_address.global-address.address}"
  ip_protocol = "TCP"
  port_range  = "80"
  labels      = "${var.labels}"
}

resource "google_compute_target_http_proxy" "http-proxy" {
  name        = "${var.name}-http"
  description = "${var.name} HTTP proxy"
  url_map     = "${google_compute_url_map.url-map.self_link}"
}

resource "google_compute_target_https_proxy" "https-proxy" {
  name             = "${var.name}-https"
  description      = "${var.name} HTTPS proxy"
  url_map          = "${google_compute_url_map.url-map.self_link}"
  ssl_certificates = ["${var.certificate-self-link}"]
  ssl_policy       = "${google_compute_ssl_policy.ssl-policy.self_link}"
}

resource "google_compute_ssl_policy" "ssl-policy" {
  name        = "${var.name}"
  description = "${var.name} policy"
  profile     = "MODERN"
}

resource "google_compute_url_map" "url-map" {
  name            = "${var.name}"
  description     = "${var.name} url map"
  default_service = "${var.backend-service-self-link}"
}

It may have change a little bit but I think the general idea is still good.

@ArnauFauquer
Copy link
Author

ArnauFauquer commented Nov 18, 2019

Thank you @migibert, I am sure that what you say can work for me. But the functionality of the resource should be the same as the console, right?.
imagen

@migibert
Copy link
Contributor

Oh right, I just checked and I think the UI is misleading as it shows a simple way to configure the load balancer, but you can go in the "advanced menu" on which you will see the resources I mentioned.

lb_advanced_menu

@ArnauFauquer
Copy link
Author

Researching more I found the most accurate solution and issue, thanks you @migibert #2373 (comment)

@ghost
Copy link

ghost commented Dec 19, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants