【发布时间】:2017-08-29 14:39:20
【问题描述】:
我不明白这一点。在执行 terraform 计划时,它抱怨该值应该是一个列表。很公平。让我们逐步分解。
错误
1 error(s) occurred:
* module.instance-layer.aws_autoscaling_group.mariadb-asg: vpc_zone_identifier: should be a list
设置
VPC 和子网是在另一个模块中使用 terraform 创建的。 该模块的输出如下:
"subnets_private": {
"sensitive": false,
"type": "string",
"value": "subnet-1234aec7,subnet-1234c8a7"
},
在我的 main.tf 中,我使用所述模块的输出将其输入到我的模块的变量中,该变量负责处理自动缩放组:
subnets_private = "${module.static-layer.subnets_private}"
这在模块中用于要求变量:
variable "subnets_private" {}
这是我配置 vpc_zone_identifier 的部分:
尝试:拆分
resource "aws_autoscaling_group" "mariadb-asg" {
vpc_zone_identifier = "${split(",",var.subnets_private)}"
尝试:列表
resource "aws_autoscaling_group" "mariadb-asg" {
vpc_zone_identifier = "${list(split(",",var.subnets_private))}"
问题
上述对 list(split( 的尝试理论上应该有效。由于 terraform 会抱怨但不打印实际值,因此很难调试。任何建议都值得赞赏。
手动填写值。
【问题讨论】:
标签: terraform