У меня есть 2 подсети (по 1 на зону доступности)
resource "aws_subnet" "infrastructure_services" {
count = "${var.enable_infrastructure_services_subnet ? 2 : 0}"
vpc_id = "${aws_vpc.this.id}"
cidr_block = "${cidrsubnet(var.cidr_block,5,count.index + 6)}"
availability_zone = "${element(var.availability_zones, count.index)}"
map_public_ip_on_launch = false
tags = "${
merge( map("Name", format("%s %s %s", var.env_name, count.index == 0 ? "Infrastructure Services A" : "Infrastructure Services B", "Subnet")),
var.global_tags,
var.vpc_tags)}"
}
Я хочу добавить эти 2 подсети в экземпляр EC2:
resource "aws_instance" "this" {
count = "${length(var.instance_names)}"
ami = "${var.ami}"
instance_type = "${element(var.instance_type, count.index)}"
availability_zone = "${element(var.availability_zones, count.index)}"
disable_api_termination = "${var.disable_api_termination}"
key_name = "${var.key_name}"
ebs_optimized = "${var.ebs_optimized}"
subnet_id="${element(aws_subnet.infrastructure_services.id,count.index)}"
vpc_security_group_ids=["${aws_security_group.infrastructure_services.id}"]
, но получить:
aws_instance.this[0]: Resource 'aws_subnet.infrastructure_services' not found for variable 'aws_subnet.infrastructure_services.id'
* aws_instance.this[1]: Resource 'aws_subnet.infrastructure_services' not found for variable 'aws_subnet.infrastructure_services.id'