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
230 stars 167 forks source link

[Bug]: Destroy of mongodbatlas_cloud_backup_snapshot_export_bucket fails with EXPORT_BUCKET_DELETE_FAILED_BUCKET_IN_USE #2325

Closed kschlesselmann closed 2 weeks ago

kschlesselmann commented 3 weeks ago

Is there an existing issue for this?

Provider Version

v1.16.2

Terraform Version

v1.8.4

Terraform Edition

Terraform Open Source (OSS)

Current Behavior

If I setup snapshot exports to S3 via terraform subsequent terraform apply calls fail if I remove the resources again.

Terraform configuration to reproduce the issue

...

resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "export_bucket" {
  depends_on = [mongodbatlas_cloud_provider_access_authorization.export_role]

  bucket_name    = local.account_backup_bucket_name
  cloud_provider = "AWS"
  iam_role_id    = mongodbatlas_cloud_provider_access_setup.export_role.role_id
  project_id     = data.mongodbatlas_project.shared.project_id
}

resource "mongodbatlas_cloud_backup_schedule" "export" {
  cluster_name = mongodbatlas_cluster.shared.name
  project_id   = data.mongodbatlas_project.shared.id
  auto_export_enabled = true

  export {
    export_bucket_id = mongodbatlas_cloud_backup_snapshot_export_bucket.export_bucket.export_bucket_id
    frequency_type = "daily"
  }

  use_org_and_group_names_in_export_prefix = true

  policy_item_daily {
    frequency_interval = 1
    retention_unit     = "days"
    retention_value    = 7
  }
}

Steps To Reproduce

Deploy a mongodbatlas_cloud_backup_schedule with an export configuration to a mongodbatlas_cloud_backup_snapshot_export_bucket and try to apply the configuration again without those resources.

Logs

Plan: 0 to add, 0 to change, 2 to destroy.
mongodbatlas_cloud_backup_snapshot_export_bucket.export_bucket: Destroying... [id=aWQ=:NjY1ZjBiMzdkZDNlYzgyOTg5YzdkNzRj-cHJvamVjdF9pZA==:NWViOTQzN2ZlYzRhZWEzNjBlMmNkM2U1]
mongodbatlas_cloud_backup_schedule.export: Destroying... [id=Y2x1c3Rlcl9uYW1l:c2hhcmVk-cHJvamVjdF9pZA==:NWViOTQzN2ZlYzRhZWEzNjBlMmNkM2U1]
mongodbatlas_cloud_backup_schedule.export: Destruction complete after 1s
╷
│ Error: error deleting snapshot export bucket (765f0b37dd3ec82989c7d74c): https://cloud.mongodb.com/api/atlas/v2/groups/5eb9437fec4aea360e2cd3e8/backup/exportBuckets/765f0b37dd3ec82989c7d74c DELETE: HTTP 400 Bad Request (Error code: "EXPORT_BUCKET_DELETE_FAILED_BUCKET_IN_USE") Detail: Failed to delete export Bucket with ID 765f0b37dd3ec82989c7d74c. Reason: Export bucket with ID 765f0b37dd3ec82989c7d74c is being used in an automatic export policy for cluster shared.. Reason: Bad Request. Params: [765f0b37dd3ec82989c7d74c Export bucket with ID 765f0b37dd3ec82989c7d74c is being used in an automatic export policy for cluster shared.]

Code of Conduct

github-actions[bot] commented 3 weeks ago

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

The ticket CLOUDP-252283 was created for internal tracking.

github-actions[bot] commented 3 weeks ago

This issue has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

kschlesselmann commented 3 weeks ago

bump

Zuhairahmed commented 3 weeks ago

Internal Jira ticket for tracking purposes: https://jira.mongodb.org/browse/HELP-60534

kschlesselmann commented 2 weeks ago

grafik

Is this intended?

gssbzn commented 2 weeks ago

Is this intended?

yes

github-actions[bot] commented 2 weeks ago

This issue has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

AgustinBettati commented 2 weeks ago

Closing issue as we will keep track directly from support case and associated ticket (https://jira.mongodb.org/browse/HELP-60534). As of latest update we are waiting for a fix from the API side when deleting the cloud backup schedule.