Hi community, I am fairly new with terraform, but I would like to manage something (if it is even possible). I would like to manage to pass different environment variables to different lambdas in a configurable way. Let’s say I have this config map:
> local.config
{
"lambdas" = [
{
"name" = "lambda1"
"envs" = [
"s2s_username" ,
"s2s_password",
"region",
"project",
]
},
{
"name" = "lambda2"
"envs" = [
"project",
]
},
]
"project" = "animals"
"s2s_password" = "cat_tail"
"s2s_username" = "lion"
}
I would like to somehow manage to have another map I could use with lambda module, which should look like this:
"lambdas" = [
{
"name" = "lambda1"
"envs" = [
"s2s_username"="lion" ,
"s2s_password"="cat_tail",
"region"="us-east-1",
"project"="animals",
]
},
{
"name" = "lambda2"
"envs" = [
"project"="animals",
]
I am passing the variables to the module and there I create a local env_vars map:
locals {
env_vars = {
s2s_username = var.s2s_username
s2s_password = var.s2s_password
region = var.region
project = var.project
}
I can not figure out how I should replace/add or flatten my config to be able to create that map in order to create lambdas with specific environment variables.