Hello!
Somewhat new to Terraform.
I am having a hard time understanding how to use the for_each and manipulate the variables from that for_each or even if it’s possble.
Let say I have this variable
variable "my_variable" {
type = list(object({
name = string
description = string
parameters = map(string)
})
)
}
The parameters = map(string)
can be diffeent between each object.
For example:
my_variable = [
{
name = "name1"
description = "desc1"
parameters = {
"--extra-py-files" = "extra1"
"--START_DT" = "start_dt1"
"--END_DT" = "end_dt1"
"--TempDir" = "bucket-dir-name1"
}
},
{
name = "name2"
description = "desc2"
parameters = {
"--extra-py-files" = "extra2"
}
}
]
My problem is that I need to do add some prefix to specific parameters if they exist in the parameter = map(string)
.
For example, if the --TempDir
is present, I would need to append the bucket name to it.
var.my_variable[0].parameters["--TempDir"]
would become s3://development-bucket-name/bucket-dir-name1
There are 3-4 transformations that I would need to do if specific element are present in the parameters = map(string)
.
I cannot understand / figure out how to do this.
Any suggestions?
Thanks a lot!