Terraform-GCP-将ip地址链接到链接到云存储桶的负载平衡器 我想要的是:
我希望有一个Terraform-GCP-将ip地址链接到链接到云存储桶的负载平衡器 我想要的是:,terraform,terraform-provider-gcp,Terraform,Terraform Provider Gcp,我希望有一个static.example.comDNS记录链接到GCS中包含我的静态图像的bucket 当我通过Cloudflare管理我的DNS时,我想我需要利用GCP可以赋予我一个选播IP的事实,将该IP链接到一个将链接到bucket的GCP负载平衡器 我目前拥有的: 已手动创建名为“静态图像”的存储桶 连接到所述铲斗的负载平衡器,使用 resource "google_compute_backend_bucket" "image_backend" { name = "e
static.example.com
DNS记录链接到GCS中包含我的静态图像的bucket
当我通过Cloudflare管理我的DNS时,我想我需要利用GCP可以赋予我一个选播IP的事实,将该IP链接到一个将链接到bucket的GCP负载平衡器
我目前拥有的:
- 已手动创建名为“静态图像”的存储桶
- 连接到所述铲斗的负载平衡器,使用
resource "google_compute_backend_bucket" "image_backend" { name = "example-static-images" bucket_name = "static-images" enable_cdn = true }
- 链接到我的存储桶的路由
resource "google_compute_url_map" "urlmap" { name = "urlmap" default_service = "${google_compute_backend_bucket.image_backend.self_link}" host_rule { hosts = ["static.example.com"] path_matcher = "allpaths" } path_matcher { name = "allpaths" default_service = "${google_compute_backend_bucket.image_backend.self_link}" path_rule { paths = ["/static"] service = "${google_compute_backend_bucket.image_backend.self_link}" } } }
- 通过以下方式创建的ip:
resource "google_compute_global_address" "my_ip" { name = "ip-for-static-example-com" }
- 从web控制台创建负载平衡器时,terraform相当于“前端配置”
resource "google_compute_global_forwarding_rule" "default" {
name = "default-rule"
target = "${google_compute_target_http_proxy.default.self_link}"
port_range = 80 // or other e.g. for ssl
ip_address = "${google_compute_global_address.my_ip.address}"
}
resource "google_compute_target_http_proxy" "default" { // or https proxy
name = "default-proxy"
description = "an HTTP proxy"
url_map = "${google_compute_url_map.urlmap.self_link}"
}