Hello,
I have an issue of passing list variable which should get his value from consul_key_prefix.shared_config.
Our concept is using modules, and for each new resource that we need to use, we are creating a new sub module for it and using the resource by calling it as module.
our main.tf has aws provider definitions and consul_key for shared_config and a list of module:
"module": {
"devex_ttrt_aurora_mysql": {
"source": "terraform-aws-modules/rds-aurora/aws",
"version": "~> 2.0",
"name": "devex-ttrt-aurora-mysql",
"engine": "aurora-mysql",
"engine_version": "5.7.mysql_aurora.2.10.0",
"username": null,
"password": null,
....
...
"subnets": "${local.subnet_id_db}", ------> should get a list
....
....
}
This is how i define in variable.tf local.subnet_id_db:
locals {
subnet_path = "eu-west-1/production/subnets"
db_list = ["db-a", "db-b", "db-c"]
}
locals {
subnet_id_db = [ data.consul_key_prefix.shared_config.subkeys["${local.subnet_path}/${local.db_list[0]}/id"],
data.consul_key_prefix.shared_config.subkeys["${local.subnet_path}/${local.db_list[1]}/id"],
data.consul_key_prefix.shared_config.subkeys["${local.subnet_path}/${local.db_list[2]}/id"]
]
}
From some reason i always get an empty map result:
Error: Invalid index
on variables.tf line 19, in locals:
19: subnet_id_db = [ data.consul_key_prefix.shared_config.subkeys["${local.subnet_path}/${local.db_list[0]}/id"],
|----------------
| data.consul_key_prefix.shared_config.subkeys is empty map of string
| local.db_list[0] is "db-a"
| local.subnet_path is "eu-west-1/production/subnets"
The given key does not identify an element in this collection value.
Dont sure what i missing here, please advise.
Thanks