基于条件(“单目标”)尝试午餐1或2个实例
错误信息获取:
132: target_id = var.ec2-2
var.ec2-2 is empty tuple
Inappropriate value for attribute "target_id": string required.使用该变量:
resource "aws_lb_target_group_attachment" "b" {
target_id = var.ec2-2
}产出:
output "ec2-2_ot" {
value = aws_instance.ec2V2[*].id
description = "the value of the network module ec2-2 id"
}变量:
variable "single-target" {
type=bool
default=false
}main.tf:
module "network_module" {
ec2-2 = module.compute_module.ec2-2_ot
}ec2发射:
resource "aws_instance" "ec2V2" {
count = var.single-target ? 0 : 1
ami = var.ec2_ami
instance_type = var.ec2_type
associate_public_ip_address = true
key_name = var.key_pair
vpc_security_group_ids = [ var.vpc-sg ]
subnet_id = var.subnet-2
user_data = file("PATH/user-data.sh")
tags = {
Name = var.ec2-2_name
}
}https://stackoverflow.com/questions/68364139
复制相似问题