######### Variable in module ##############
variable "instanceTargetAttachment" {
type = map(object({
targetGroupArn = string
instanceID = string
port = number
}))
default = {}
}
####### Actual Value passed ############
variable "instanceTargetAttachment" {
default = {
target-11 = {
targetGroupArn = "arn:aws:elasticloadbalancing:us-east-1:730335241082:targetgroup/terraformTest-80/656f5c02aa6183b"
instanceID = ["i-09b14edc562c8778t", "i-09b14edc562c8778t"]
port = 80
}
}
}
}
I am not able to extract single value to target_group_arn in aws_lb_target_group_attachment
the value in the output is like
terraform output
WebserverInstanceId = {
"webserver-1" = "i-00aa69a47495d5dcf"
"webserver-2" = "i-0fa626c1a9ab4d52b"
}
targetGroupArn = {
"terraformTest-80" = "arn:aws:elasticloadbalancing:us-east-1:730335241082:targetgroup/terraformTest-80/656f5c02aa6183"
"terraformTest-81" = "arn:aws:elasticloadbalancing:us-east-1:730335241082:targetgroup/terraformTest-81/814f284b095c86"
}
I want to use the values in a way that single target group is picked and attach all the given instances and then second target group and attach the given instances to that with the port given.
kindly help
Thanks