变量.tf
variable "region" {
default = "us-central1"
}
variable "zone" {
description = "override default zone specified in region_params"
default = ""
}
variable "region_params" {
description = "Map of default zones for each region. Can be overridden using the `zone`."
type = map(string)
default = {
asia-east1 = {
zone = "asia-east1-b"
}
asia-east2 = {
zone = "asia-east2-b"
}
asia-northeast1 = {
zone = "asia-northeast1-b"
}
asia-south1 = {
zone = "asia-south1-b"
}
asia-southeast1 = {
zone = "asia-southeast1-b"
}
australia-southeast1 = {
zone = "australia-southeast1-b"
}
europe-north1 = {
zone = "europe-north1-b"
}
europe-west1 = {
zone = "europe-west1-b"
}
europe-west2 = {
zone = "europe-west2-b"
}
europe-west3 = {
zone = "europe-west3-b"
}
europe-west4 = {
zone = "europe-west4-b"
}
northamerica-northeast1 = {
zone = "northamerica-northeast1-b"
}
southamerica-east1 = {
zone = "southamerica-east1-b"
}
us-central1 = {
zone = "us-central1-b"
}
us-east1 = {
zone = "us-east1-b"
}
us-east4 = {
zone = "us-east4-b"
}
us-west1 = {
zone = "us-west1-b"
}
us-west2 = {
zone = "us-west2-b"
}
}
}
variable "network" {
}
variable "instance_tags" {
default = []
}
variable "ip_cidr_range" {
description = "Subnetwork range - required"
}
variable "environment" {
description = "The build environment tier"
default = "dev"
}
output "nat-gateway-ip" {
value = module.nat.external_ip
}
./terraform0.13 init-重新配置
There are some problems with the configuration, described below. The Terraform configuration must be valid before initialization so that Terraform can determine which modules and providers need to be installed. ╷ │ Error: Invalid default value for variable │ │ on variables.tf line 71, in variable "region_params": │ 71: default = { │ 72: asia-east1 = { │ 73: zone = "asia-east1-b" │ 74: } │ 75: asia-east2 = { │ 76: zone = "asia-east2-b" │ 77: } │ 78: asia-northeast1 = { │ 79: zone = "asia-northeast1-b" │ 80: } │ 81: asia-south1 = { │ 82: zone = "asia-south1-b" │ 83: } │ 84: asia-southeast1 = { │ 85: zone = "asia-southeast1-b" │ 86: } │ 87: australia-southeast1 = { │ 88: zone = "australia-southeast1-b" │ 89: } │ 90: europe-north1 = { │ 91: zone = "europe-north1-b" │ 92: } │ 93: europe-west1 = { │ 94: zone = "europe-west1-b" │ 95: } │ 96: europe-west2 = { │ 97: zone = "europe-west2-b" │ 98: } │ 99: europe-west3 = { │ 100: zone = "europe-west3-b" │ 101: } │ 102: europe-west4 = { │ 103: zone = "europe-west4-b" │ 104: } │ 105: northamerica-northeast1 = { │ 106: zone = "northamerica-northeast1-b" │ 107: } │ 108: southamerica-east1 = { │ 109: zone = "southamerica-east1-b" │ 110: } │ 111: us-central1 = { │ 112: zone = "us-central1-f" │ 113: } │ 114: us-east1 = { │ 115: zone = "us-east1-b" │ 116: } │ 117: us-east4 = { │ 118: zone = "us-east4-b" │ 119: } │ 120: us-west1 = { │ 121: zone = "us-west1-b" │ 122: } │ 123: us-west2 = { │ 124: zone = "us-west2-b" │ 125: } │ 126: } │ │ This default value is not compatible with the variable's type constraint: element "asia-east2": string required.
答案1
尝试将其设置为 us-central-1。您的区域格式错误,数字前需要加一个破折号。此外,您不需要指定 a、b 或 c,因为 terraform 会从您的子网设置中获取信息。