Terraform support for Database Triggers using Function events
The Database Triggers resource supports only EventBridge right now. It would be awesome to see support for Function events as well

-
Ben commented
I went through the exercise today of deploying a database trigger that calls a function using mongodbatlas_event_trigger.
There's no mechanism to deploy the function code through Terraform - the above resource needs you to first create a JavaScript function either through the UI or CLI, and refer to it by an ID you extract from the URL in the UI.
Basically it would be great if mongodbatlas_event_trigger could be a little more like aws_lambda_function where I could bring in the function's JavaScript file from a path or an S3 bucket (we use an S3 bucket for Lambda zips in our workflow).
This is what my Lambda tfs look like:
data "aws_s3_object" "my_lambda_function" {
bucket = var.s3_bucket_deployment
key = "lambda/go1.x/web/my_lambda_function.zip"
}resource "aws_lambda_function" "my_lambda_function" {
function_name = "${var.deployment}_my_lambda_function"
s3_bucket = data.aws_s3_object.my_lambda_function.bucket
s3_key = data.aws_s3_object.my_lambda_function.key
s3_object_version = data.aws_s3_object.my_lambda_function.version_id...
Would be great to be able to grab a .js from the path or S3 and publish the function either in it's own resource or as part of mongodbatlas_event_trigger.
-
AdminZuhair (Admin, MongoDB) commented
Thanks for reaching out Falcon. If you look at latest docs for resource mongodbatlas_event_trigger (https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/event_trigger) we support Database Trigger with Function as our first example. Can you take a look and let us know if this helps?