변수.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 초기화 -재구성
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로 설정해 보세요. 지역 형식을 잘못 지정했습니다. 숫자 앞에 대시가 필요합니다. 또한 terraform은 서브넷 설정에서 정보를 가져오므로 a, b 또는 c를 지정할 필요가 없습니다.