I would like to retrieve the value of the following pin_connection_details
and pin_task_position
from the variable below:
How do I retrieve it?
Below is the variable from which these values need to be retrieved:
variable "config_settings" {
description = "Configuration settings for the Pinpoint"
type = list(object({
name = string
area = string
version = string
pin_config = object({
pin_encrypt = optional(bool, false)
pin_mode = optional(bool, false)
pin_types = map(object({
pin_name = string
pin_port = string
pin_connection_details = optional(string, null)
timer = object({
start = string
stop = string
})
}))
})
pin_tasks = list(object({
pin_task_name = string
pin_task_position = optional(string, null)
}))
}))
}
How can I resolve this issue?
I extended a bit your example to show how it can be achied
variable "config_settings" {
description = "Configuration settings for the Pinpoint"
type = list(object({
name = string
area = string
version = string
pin_config = object({
pin_encrypt = optional(bool, false)
pin_mode = optional(bool, false)
pin_types = map(object({
pin_name = string
pin_port = string
pin_connection_details = optional(string, null)
timer = object({
start = string
stop = string
})
}))
})
pin_tasks = list(object({
pin_task_name = string
pin_task_position = optional(string, null)
}))
}))
default = [{
area = "area"
name = "name"
pin_config = {
pin_encrypt = false
pin_mode = false
pin_types = {
"key" = {
pin_connection_details = "pin_connection_details"
pin_name = "pin_name"
pin_port = "pin_port"
timer = {
start = "start"
stop = "stop"
}
}
}
}
pin_tasks = [{
pin_task_name = "pin_task_name"
pin_task_position = "pin_task_position"
}]
version = "version"
}]
}
output "pin_connection_details" {
value = var.config_settings[0].pin_config.pin_types["key"].pin_connection_details
}
output "pin_task_position" {
value = var.config_settings[0].pin_tasks[0].pin_task_position
}
you can play with it using 'terraform plan'
❯ terraform plan
Changes to Outputs:
+ pin_connection_details = "pin_connection_details"
+ pin_task_position = "pin_task_position"
Hope it helps