Terraform GCP - NAT网关无法创建

时间:2018-03-16 09:25:46

标签: google-cloud-platform google-compute-engine terraform google-cloud-networking

使用terraform使用此模块创建nat-gateway。 https://registry.terraform.io/modules/GoogleCloudPlatform/nat-gateway/google/1.1.3

使用此代码:

module "nat" {
        source                  = "GoogleCloudPlatform/nat-gateway/google"
        region                  = "${var.gcloud-region}"
        network                 = "${google_compute_network.vpc-network.name}"
        subnetwork              = "${google_compute_subnetwork.vpc-subnetwork-public.name}"
        machine_type    = "${var.vm-type-nat-gateway}"
}

其他摘要:

variable "gcloud-region"                        { default = "europe-west1" }
variable "vm-type-nat-gateway"                  { default = "n1-standard-2"}

resource "google_compute_network" "vpc-network" {
    name                        = "foobar-vpc-network"
    auto_create_subnetworks     = false
}


resource "google_compute_subnetwork" "vpc-subnetwork-public" {
    name                        = "foobar-vpc-subnetwork-public"
    ip_cidr_range               = "10.0.1.0/24"
    network                     = "${google_compute_network.vpc-network.self_link}"
    region                      = "${var.gcloud-region}"
    private_ip_google_access    = false
}

=====

  
      
  • module.nat.google_compute_route.nat-gateway:发生了1个错误:

  •   
  • module.nat.google_compute_route.nat-gateway:element:element()不能与空列表一起使用:

  •   
     

$ {element(split(" /",element(module.nat-gateway.instances [0],0)),   10)}

上面出现错误,整个terraform脚本停止,无法运行

任何更改

terraform applyterraform destroy

导致此问题的任何可能问题?

0 个答案:

没有答案