Hello
I need community help)
I have a var with output like below
private_subnets = {
+ eu-west-1a = [
+ "subnet-0b53fe5230ebe5c78",
]
+ eu-west-1b = [
+ "subnet-0eab295109e89e12a",
]
+ eu-west-1c = [
+ "subnet-02124519fb318a211",
]
How can I extract values (subnet id) by providing a key (availability zone)?
Also my part of code
module "ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "~> 3.0"
count = length(local.azs)
name = "${local.server_name}-${count.index +1}"
subnet_id = element(local.az_subnet_ids[local.azs], count.index)
Error: Invalid index
β
β on runner.tf line 104, in module "ec2_instance":
β 104: subnet_id = element(local.az_subnet_ids[local.azs], count.index)
β βββββββββββββββββ
β β local.az_subnet_ids is object with 3 attributes
β β local.azs is tuple with 3 elements
β
β The given key does not identify an element in this collection value: string required.