Skip to content

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

@kschlesselmann

Description

@kschlesselmann

Is there an existing issue for this?

  • I have searched the existing issues

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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    not_staleNot stale issue or PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions