在部署GCP作曲者资源时,我遇到了Terraform代码错误:
section
-name
。 section
可能不包含方括号,闭合方括号或连字符,name
可能不包含分号或等号。整个属性键可能不包含句点。badRequest 部署此GCP资源时出现问题:https://www.terraform.io/docs/providers/google/r/composer_environment.html
这是我的代码:
Variables.tf文件:
variable "composer_airflow_version" {
type = "map"
default = {
image_version="composer-1.6.1-airflow-1.10.1"
}
}
variable "composer_python_version" {
type = "map"
default = {
python_version="3"
}
}
my-composer.tf文件:
resource "google_composer_environment" "composer-beta" {
provider= "google-beta"
project = "my-proyect"
name = "${var.composer_name}"
region = "${var.region}"
config {
node_count = "${var.composer_node_count}"
node_config {
zone = "${var.zone}"
machine_type = "${var.composer_machine_type}"
network = "${google_compute_network.network.self_link}"
subnetwork = "${lookup(var.vpc_subnets_01[0], "subnet_name")}"
}
software_config {
airflow_config_overrides="${var.composer_airflow_version}",
airflow_config_overrides="${var.composer_python_version}",
}
}
depends_on = [
"google_service_account.comp-py3-dev-worker",
"google_compute_subnetwork.subnetwork",
]
}
根据错误消息,错误的根本原因似乎与terraform代码中的software_config部分有关。我知道变量“ composer_airflow_version”和“ composer_python_version”应为“ map”类型,因此,我将其设置为地图格式。
如果有人可以确定错误原因并告诉我要进行的调整,我真的很感激。我可能应该对变量进行更改,但我不知道它是什么。 :-(
预先感谢, 何塞
答案 0 :(得分:1)
根据文档,airflow_config_overrides,pypi_packages, env_variables , image_version 和 python_version 应该直接位于 software_config 下
Variables.tf文件:
variable "composer_airflow_version" {
default = "composer-1.6.1-airflow-1.10.1"
}
variable "composer_python_version" {
default = "3"
}
my-composer.tf文件:
resource "google_composer_environment" "composer-beta" {
provider= "google-beta"
project = "my-proyect"
name = "${var.composer_name}"
region = "${var.region}"
config {
node_count = "${var.composer_node_count}"
node_config {
zone = "${var.zone}"
machine_type = "${var.composer_machine_type}"
network = "${google_compute_network.network.self_link}"
subnetwork = "${lookup(var.vpc_subnets_01[0], "subnet_name")}"
}
software_config {
image_version = "${var.composer_airflow_version}",
python_version = "${var.composer_python_version}",
}
}
depends_on = [
"google_service_account.comp-py3-dev-worker",
"google_compute_subnetwork.subnetwork",
]
}