在代码.tf文件中:
resource "aws_vpc_peering_connection" "this_1" {
count = var.create_peering_1 ? 1 : 0
peer_owner_id = var.peer_account_id_1
peer_vpc_id = var.vpc_peer_id_1
vpc_id = module.vpc.vpc_id
auto_accept = var.auto_accept_peering_1
}
variables.tf中的变量:
variable "create_peering_1" {
description = "Create peering connection, 0 to not create"
default = 0
}
我得到的错误:
Error: Incorrect condition type
on peering_1.tf line 6, in resource "aws_vpc_peering_connection" "this_1":
6: count = var.create_peering_1 ? 1 : 0
|----------------
| var.create_peering_1 is 0
The condition expression must be of type bool.
我该如何解决此错误?
答案 0 :(得分:2)
将0
用作false
variable "create_peering_1" {
description = "Create peering connection, false to not create"
default = false
type = bool
}
答案 1 :(得分:1)
variable "create_peering_1" {
type = bool
default = true
布尔值必须为true或false。