mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
242 stars 168 forks source link

config_full_document_before not working in EventTriggers #616

Closed jon-king-mindbodyonline closed 2 years ago

jon-king-mindbodyonline commented 2 years ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.0.11
on darwin_amd64
+ provider registry.terraform.io/mongodb/mongodbatlas v1.1.1

Terraform Configuration File

resource "mongodbatlas_event_trigger" "test" {
  project_id = "123456"
  app_id = "123456"
  name = "test-trigger"
  type = "DATABASE"
  disabled = false
  config_operation_types = ["INSERT", "UPDATE"]
  config_database = "dbname"
  config_collection = "cname"
  config_service_id = "123456"
  config_match = "{\"updateDescription.updatedFields\":{\"status\":\"blocked\"}}"
  config_project = "{\"operationType\": 1, \"updateDescription.updatedFields\":{\"status\":\"blocked\"}}"
  config_full_document = true
  config_full_document_before = true
  event_processors {
    aws_eventbridge {
      config_account_id = "123456"
      config_region = "us-west-1"
    }
  }
}

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. Check the Atlas UI for the Trigger
  4. Also check the Realm API directly
    > BEARERTOKEN=$(curl -s --request POST  --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --data '{"username": "<public-key>", "apiKey": "<private-key>"}' \
    https://realm.mongodb.com/api/admin/v3.0/auth/providers/mongodb-cloud/login | jq -r '.access_token')
    > curl --request GET \
    --header 'Content-Type: application/json' \
    --header "Authorization: Bearer ${BEARERTOKEN}" \
    https://realm.mongodb.com/api/admin/v3.0/groups/<project_id>/apps/<application_id>/triggers

Expected Behavior

That the trigger be created in Realm with "Document Preimage" enabled (FullDocumentBeforeChange in the API and Go library)

Actual Behavior

Trigger is successfully created but with Document Preimage false, confirmed in Atlas UI and API. There's a good chance, based on trace output, this is a Realm API issue:

Debug Output

trace.log

themantissa commented 2 years ago

@jon-king-mindbodyonline thank you for the complete report. I've created an internal ticket to have our developers take a look. We'll get back to you as soon as we have more information. ticket INTMDB-281

themantissa commented 2 years ago

@jon-king-mindbodyonline we are about to release the fix in version 1.2. The pre-release is completed if you'd like to test first. Thank you.

themantissa commented 2 years ago

Fix in 1.2