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

Errors when creating or importing timeseries online archive #1081

Closed marina-chibizova closed 1 year ago

marina-chibizova commented 1 year ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

 v1.3.9

Terraform Configuration File

resource "mongodbatlas_online_archive" "name" {
    project_id   = var.project_id
    cluster_name = var.cluster_name
    db_name      = var.database_name
    coll_name    = var.collection_name

    partition_fields {
        field_name = "pairId"
        order = 1
    }

    criteria {
        type = "DATE"
        date_field = "timestamp"
        date_format = "ISODATE"
        expire_after_days = 7
    }

}

Steps to Reproduce

Option 1 - trying to add an online archive to a timeseries collection

  1. terraform init
  2. Pull request -> Merge (Auto apply)

Option 2 - importing manually created online archive with timeseries type

  1. terraform import mongodbatlas_online_archive.users_archive <project_id>-<cluster_name>-<archive_id>

Expected Behavior

Option 1 After a successful run in terraform, a new online archive is expected to appear in Mongo and the documents matching defined criteria (the current date is greater than the value of the date field specified here plus the number of days specified via the expire_after_days parameter)

Option 2 Import existing timeseries online archive in terraform

Actual Behavior

Option 1 Online archive is created in Mongo, but the following error appears: Error starting archive: archive collection type does not match the collection type found

Option 2 Error: could not import Online Archive <archive_id> in project <project_id>, error GET https://cloud.mongodb.com/api/atlas/v1.0/groups/<project_id>/clusters/cluster_name/onlineArchives/<archive_id>: 404 (request "RESOURCE_NOT_FOUND") Cannot find resource Online archive with id <archive_id>.

Additional Context

Nowhere in the set up process there is a place to define collection type (timeseries). type = DATE refers to archiving criteria, but not to the collection type itself. While UI provides this as a checkbox when creating an archive.

Reference

https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Online-Archive/operation/createOnlineArchive

martinstibbe commented 1 year ago

@marina-chibizova Will try to replicate issue

martinstibbe commented 1 year ago

@marina-chibizova I was able to import one I created but it did bring up your error in option 1 will track a fix for this in INTMDB-648

Zuhairahmed commented 1 year ago

just as an update @marina-chibizova this issue has been picked up for v1.8.2 release which should be published in the next month or two.