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
Hi we working to enhance the the use of Triggers and Functions in Terraform, but this effort still several quarters away. Feel free to reach on in the interim in case of any questions and happy to help.
-
Kimmo commented
The documentation has eventbridge as the "event processor" in the example, which is not really helpful - or at least quite misleading if the functions are configured that way.
-
Ben Giddins 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.