I have an aws_lambda_function resource like below:
resource "aws_lambda_function" "mylambda" {
#...
environment {
variables = {
FOO = 1
}
}
}
I'm tring to add some environment variables dynamically based on my var.enable_vars
variable "enable_vars" {
type = bool
default = false
}
resource "aws_lambda_function" "mylambda" {
#...
environment {
variables = {
FOO = 1
#### if var.enable_vars == true
# BAR = 2
# BAZ = 3
}
}
}
How to achieve that? Is not clear to me if a dynamic
block can be used there.