1

使用 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任何变化,

任何可能的问题导致这个?

4

0 回答 0