Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Terraform-GCP-将ip地址链接到链接到云存储桶的负载平衡器 我想要的是:_Terraform_Terraform Provider Gcp - Fatal编程技术网

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相当于“前端配置”

看起来你只是错过了一次机会

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

e、 g:

希望这有帮助

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}"
}