首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Terraform - GCP -将ip地址链接到连接到云存储桶的负载均衡器。

Terraform - GCP -将ip地址链接到连接到云存储桶的负载均衡器。
EN

Stack Overflow用户
提问于 2019-05-06 16:32:51
回答 1查看 725关注 0票数 4

我想要的:

我希望有一个static.example.com DNS记录,它链接到包含我的静态映像的GCS中的一个桶。

当我通过Cloudflare管理我的DNS时,我认为我需要使用GCP可以赋予我anycast-IP的事实,将该IP链接到GCP负载均衡器,而GCP负载均衡器将被链接到bucket。

我现在拥有的是:

  • 已经手动创建了一个名为“静态图像”的桶。
  • 将负载均衡器链接到所述桶,使用 资源"google_compute_backend_bucket“"image_backend”{ name =“示例-静态-映像”bucket_name =“静态-映像”enable_cdn = true }
  • 连接到我的桶的路由 资源"google_compute_url_map“"urlmap”{ name = "urlmap“default_service = default_service = "static.example.com”path_matcher =“allpath”} path_matcher { name =“allpath”default_service= "${google_compute_backend_bucket.image““"${google_compute_backend_bucket.image_backend.self_link}”{ paths = "/static“服务= path_rule }}
  • 通过以下方式创建的ip: 资源"google_compute_global_address“"my_ip”{ name =“ip-for-static”}

我缺少的是:

  • 当从web控制台创建负载均衡器时,terraform的等效于“前端配置”
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-20 15:11:01

看起来你只是错过了一个转发规则目标代理

规则上的terraform文档有一个很好的例子。

例如:

代码语言:javascript
运行
复制
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}"
}

希望这能帮上忙!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56009157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档