当我尝试运行此配置时遇到语法错误,这是在自动更新AWS提供程序之后发生的。
variable "availability_zone" {
default = "*****"
}
variable "vpc_id" {
default = "*******"
}
variable "subnet_count" {
default = "1"
}
data "aws_vpc" "env" {
id = "${var.vpc_id}"
}
data "external" "net" {
program = ["/atf/bin/atf-subnet-reservation-alloc"]
query = {
subnet_count = "${var.subnet_count}"
vpc_id = "${var.vpc_id}"
}
}
resource "aws_subnet" "net" {
count = "${var.subnet_count}"
vpc_id = "${data.aws_vpc.env.id}"
availability_zone = "${var.availability_zone}"
cidr_block = "${cidrsubnet(data.aws_vpc.env.cidr_block, 8, element(split(",",data.external.net.result.subnets),count.index))}"
map_public_ip_on_launch = "true"
provisioner "local-exec" {
when = "destroy"
command = "/atf/bin/atf-subnet-reservation-free ${self.cidr_block}"
on_failure = "continue"
}
}
崩溃输出:
module.aws_env.aws_subnet.net:发生1个错误:10月22日星期一 14:05:15 2018 :: * module.aws_env.aws_subnet.net: __builtin_StringToInt:strconv.ParseInt:解析“”:语法无效:2018年10月22日星期一14:05:15 :: $ {cidrsubnet(data.aws_vpc.env.cidr_block,8, element(split(“,”,data.external.net.result.subnets),count.index))}