Terraform 使用
import
将已经创建的机器转换成 terraform 并管理
resource "google_compute_instance" "compute-00" {}
$ terraform import google_compute_instance.compute-00 projects/PROJECT_ID/zones/REGION/instances/compute-00
gcp lb
- cloud func 和 cloud run 使用的 resource 是不同的,但是假如你有个 cloud func 它其实是会先创建一个 cloud run,在配置 lb 时写 cloud run 名称 这个 lb 也是能工作的。
根据路由区分 cloud func 两种写法
path_rule {
paths = ["/terraform/*"]
route_action {
url_rewrite {
path_prefix_rewrite = "/"
}
weighted_backend_services {
backend_service = google_compute_backend_service.terraform.id
weight = 100
}
}
}
route_rules {
priority = 1
service = google_compute_backend_service.terraform.id
match_rules {
prefix_match = "/terraform/"
}
route_action {
url_rewrite {
path_prefix_rewrite = "/"
}
}
}