Terraform - Creating multiple S3 event notification with different destinations

Hi,

I need to add Lambda and SQS event notifications for the same bucket. I am able to configure notifications for multiple Lambda functions or multiple SQS queues but it doesnt work for both Lambda and SQS at the same time. I am trying with the below code. Kindly advise what I am missing here.

resource “aws_lambda_permission” “allow_bucket” {
#statement_id = “AllowExecutionFromS3Bucket”
action = “lambda:InvokeFunction”
function_name = var.lambda_arn
principal = “s3.amazonaws.com
source_arn = var.bucket_arn
}

resource “aws_s3_bucket_notification” “bucket_notification_lambda” {
bucket = var.bucket_id
queue {
id = var.id_sqs
queue_arn = var.queue_arn
events = var.events
filter_suffix = var.sqs_suffix
filter_prefix = var.sqs_prefix
}
lambda_function {
id = var.id_sftp
lambda_function_arn = var.lambda_arn
events = var.events
filter_prefix = var.lambda_prefix
filter_suffix = var.lambda_suffix
}

depends_on = [aws_lambda_permission.allow_bucket]
}

Thanks & Regards