gpt4 book ai didi

google-cloud-platform - Terraform - Google 内部负载均衡器

转载 作者:行者123 更新时间:2023-12-04 07:02:33 29 4
gpt4 key购买 nike

Terraform 是否支持 Google 的内部负载均衡器?
https://cloud.google.com/compute/docs/load-balancing/internal/

最佳答案

截至 2017 年 9 月,确实如此!不幸的是,它的文档并不是那么好。

这是一个非常粗略的例子,可能不仅仅是通过复制/粘贴工作!

resource "google_compute_instance_group" "elasticsearch-cluster" {
name = "elasticsearch-cluster"
description = "Terraform test instance group"

instances = [
"${google_compute_instance.elasticsearch-compute-instance.*.self_link}"
]

named_port {
name = "elasticsearch-api"
port = "9200"
}

named_port {
name = "elasticsearch-transport"
port = "9300"
}

zone = "us-central1-a"
}

resource "google_compute_forwarding_rule" "elasticsearch-forwarding-rule" {
name = "elasticsearch-lb"
load_balancing_scheme = "INTERNAL"
backend_service = "${google_compute_region_backend_service.elasticsearch-lb.self_link}"
ports = [ "9200", "9300" ]
}

resource "google_compute_region_backend_service" "elasticsearch-lb" {
name = "elasticsearch-lb"
protocol = "TCP"
timeout_sec = 10
session_affinity = "NONE"

backend {
group = "${google_compute_instance_group.elasticsearch-cluster.self_link}"
}

health_checks = ["${google_compute_health_check.elasticsearch-healthcheck.self_link}"]
}

resource "google_compute_health_check" "elasticsearch-healthcheck" {
name = "elasticsearch-healthcheck"
check_interval_sec = 5
timeout_sec = 5

tcp_health_check {
port = "9200"
}
}

关于google-cloud-platform - Terraform - Google 内部负载均衡器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40030314/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com