Terraform conflicting configuration arguments with aws_lambda_function

Error: Conflicting configuration arguments
│ 
│   with module.lambda.aws_lambda_function.lambda,
│   on ../../lambda.tf line 15, in resource "aws_lambda_function" "lambda":
│   15:   filename                       = "${var.use_s3_key ? null : var.file_path}"
│ 
│ "filename": conflicts with image_uri
╵
╷
│ Error: Conflicting configuration arguments
│ 
│   with module.lambda.aws_lambda_function.lambda,
│   on ../../lambda.tf line 18, in resource "aws_lambda_function" "lambda":
│   18:   image_uri                      = "${var.use_s3_key ? null : var.image_uri}" 
│ 
│ "image_uri": conflicts with filename

Guys what I should do to avoid this error please.

Hi @mohamedoabbiit,

It seems that you are trying to set two arguments that are mutually exclusive with one another. You can set only one of these arguments at a time.

If your intent is for var.use_s3_key to set image_url instead of filename then I think you have your logic inverted for image_uri, because you are setting it only when var.use_s3_key isn’t set.

image_uri = var.use_s3_key ? var.image_uri : null