terraform-provider-mongodbatlas: `app_id` In documentation is ambiguous for MongoDB Atlas Event Trigger

tl;dr;

The app_id to create an Atlas Event Trigger in the documentation is ambiguous. What is your application in the doc talking about here?

app_id - (Required) The ObjectID of your application.

Terraform CLI and Terraform MongoDB Atlas Provider Version

$ terraform --version
Terraform v1.3.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.45.0
+ provider registry.terraform.io/mongodb/mongodbatlas v1.6.1

Terraform Configuration File

# database to keep track of all otters on earth

provider "mongodbatlas" {
  public_key  = var.atlas_public_key
  private_key = var.atlas_private_key
}
resource "mongodbatlas_project" "otter_atlas" {
  name   = "otter-otter"
  org_id = var.atlas_org_id
}
resource "mongodbatlas_advanced_cluster" "otter_free" {
  project_id   = mongodbatlas_project.otter_atlas.id
  name         = "otter-otter"
  cluster_type = "REPLICASET"

  replication_specs {
    region_configs {
      electable_specs {
        instance_size = "M0" # free
      }
      provider_name         = "TENANT"
      backing_provider_name = "AWS"
      region_name           = var.atlas_region
      priority              = 1
    }
  }
  depends_on = [mongodbatlas_project.otter_atlas]
}

resource "mongodbatlas_database_user" "db-user" {
  username           = var.atlas_dbuser
  password           = var.atlas_dbpassword
  auth_database_name = "admin"
  project_id         = mongodbatlas_project.otter_atlas.id
  roles {
    role_name     = "readWriteAnyDatabase"
    database_name = "admin"
  }
  depends_on = [mongodbatlas_project.otter_atlas]
}

resource "mongodbatlas_event_trigger" "otter" {
  project_id             = mongodbatlas_project.otter_atlas.id
  app_id                 = mongodbatlas_advanced_cluster.otter_free.id
  name                   = "Event trigger to AWS Event Bridge"
  type                   = "DATABASE"
  disabled               = false
  config_operation_types = ["INSERT", "UPDATE", "REPLACE", "DELETE"]
  config_database        = "otterotter"
  config_collection      = "otter"
  config_service_id      = "1"
  config_full_document   = true
  event_processors {
    aws_eventbridge {
      config_region     = var.aws_region
      config_account_id = var.aws_account_id
    }
  }
  depends_on = [mongodbatlas_project.otter_atlas, mongodbatlas_advanced_cluster.otter_free]
}

data "mongodbatlas_event_triggers" "otter" {
  project_id = mongodbatlas_event_trigger.otter.project_id
  app_id     = mongodbatlas_event_trigger.otter.app_id
}

Steps to Reproduce

  1. $ terraform apply -auto-approve

Expected Behavior

  1. Created the database trigger with the cluster’s ID.
  2. Helpful documentation on what the app should be relating to the app_id

Actual Behavior

│ Error: error creating MongoDB EventTriggers (63935a667e4e335fe1d47e63): POST https://realm.mongodb.com/api/admin/v3.0/groups/63935a667e4e335fe1d47e63/apps/Y2x1c3Rlcl9pZA==:NjM5MzVhNmIwNWUxMTI3M2IzZmFhOGE4-Y2x1c3Rlcl9uYW1l:ZmVlZGJhY2stb3R0ZXI=-cHJvamVjdF9pZA==:NjM5MzVhNjY3ZTRlMzM1ZmUxZDQ3ZTYz/triggers: 404 (request "") app not found
│ 
│   with mongodbatlas_event_trigger.otter,
│   on atlas.tf line 60, in resource "mongodbatlas_event_trigger" "otter":
│   60: resource "mongodbatlas_event_trigger" "otter" {

Debug Output

Additional Context

Not needed.

References

According to the doc for event triggers we need the app_id but the example shows a string as an example. In the Argument Reference section it doesn’t help to know what the Application should be.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

@TylerSustare @Ballymultani @Futhark v1.8.1 has been published to the Terraform Public Registry! take a spin and let us know if you need anything else.

@TylerSustare @Ballymultani fix for this has been picked up for v1.8.1 sprint which should be released in ~3 weeks. @Futhark yes we are planning to integrate Atlas App Services into Atlas Admin API/Terraform Provider, but this is a large effort and still several quarters away. Feel free to reach out in future and can share updates if you need.

Is there any plan to add App Services resource types?

Hi, any update?

hi @Ballymultani @TylerSustare we should have an update on this soon. feel free to reach out if you need anything else in the interim.

@TylerSustare thanks for highlighting error, this is going to require a code change. Will include as part of INTMDB-517 and let you know when issue has been resolved. Feel free to reach out if you need anything else in the interim.

Doc update in internal tracking INTMDB-517. Should go out as part of near term release.

Thanks @TylerSustare. To learn more about what is and how to pull app_id see here: https://www.mongodb.com/docs/atlas/app-services/admin/api/v3/#section/Project-and-Application-IDs Also you are right, we can make this more clear in our docs. Will add this supporting link to help future users. Appreciate the feedback here.