【问题标题】:GCP SSL Proxy LoadBalancer via Terraform通过 Terraform 的 GCP SSL 代理负载平衡器
【发布时间】:2021-05-14 10:09:51
【问题描述】:
我们正在 GCP 上为我们的应用程序创建基础架构,该应用程序在 GCP 上使用 SSL Porxy 负载均衡器。我们使用 Terraform 进行部署,并且正在努力通过 terraform 创建 SSL 代理负载均衡器。
如果有人可以指向示例代码或指向我可以找到一些资源来创建负载均衡器的方向
【问题讨论】:
标签:
google-cloud-platform
terraform
load-balancing
【解决方案1】:
你可以试试下面的example:
resource "google_compute_target_ssl_proxy" "default" {
name = "test-proxy"
backend_service = google_compute_backend_service.default.id
ssl_certificates = [google_compute_ssl_certificate.default.id]
}
resource "google_compute_ssl_certificate" "default" {
name = "default-cert"
private_key = file("path/to/private.key")
certificate = file("path/to/certificate.crt")
}
resource "google_compute_backend_service" "default" {
name = "backend-service"
protocol = "SSL"
health_checks = [google_compute_health_check.default.id]
}
resource "google_compute_health_check" "default" {
name = "health-check"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
port = "443"
}
}
考虑到Health Check 指向端口443/tcp,如果您想要不同的端口,请在此处更改。