I am trying to extract the values from map variable based on certain conditions as below :-
Variables.tf File content
variable "users" {
type = "map"
default = {
"101" = "[email protected]"
"102" = "[email protected]"
"103" = "[email protected]"
"104" = "[email protected]"
"105" = "[email protected]"
"106" = "[email protected]"
}
}
Below is my main.tf file
module "instance" {
instance_private_ip = ["11.12.13.x"]
dns_map = ["y"]
users = ["z"]
}
module "instance2" {
instance_private_ip = ["11.12.14.a"]
dns_map = ["b"]
users = ["c"]
}
The value x should be all even numbers in users variables like - 102, 104 and so on. The value y should be same as x The value z should be corresponding to x and y. The value a should be all even numbers in users variables like - 101, 103 and so on. The value b should be same as a The value c should be corresponding to a and b. Example as below
module "instance" {
instance_private_ip = ["11.12.13.102", "11.12.13.104", "11.12.13.106"]
dns_map = ["102","104","106"]
users = ["[email protected]","[email protected]","[email protected]"]
}
module "instance2" {
instance_private_ip = ["11.12.14.101", "11.12.14.103", "11.12.14.105"]
dns_map = ["101","103","105"]
users = ["[email protected]","[email protected]","[email protected]"]
}
I am trying with ${element(var.notebook[count.index])} but it will give me the username and not the left side variable.
Any help is appreciated