I'm managing AWS lambda functions with terraform module. Now I want to add dead_letter_config to one of the lambda functions, but keep other functions unchanged.
I'm trying to add dead_letter_config field (which is optional in aws_lambda_function resource) to the module, but I can't find how I can make dead_letter_config field available in only a specific lambda function, and make that field ignored in other callers.
My terraform is v0.12.28, so I tried to use null default value on a variable.
resource "aws_lambda_function" "lambda" {
...
dead_letter_config {
target_arn = var.dead_letter_config_target
}
variable "dead_letter_config_target" {
default = null
type = string
}
But target_arn field is required under dead_letter_queue field, so terraform plan fails.
Error: "dead_letter_config.0.target_arn": required field is not set
Is there any good way to ignore an entire field conditionally?