Steps to remove export bucket from a cluster

What are the steps to remove an export bucket associated with a cluster?

My situation:

I’ve successfully created a cluster, back up schedule with export bucket to AWS S3 with Terraform.

However when trying to destroy the created resources, deletion step for “mongodbatlas_cloud_backup_snapshot_export_bucket” resource hangs indefinitely until I SIGINT with ctrl+c the terraform destroy command.

I’ve also tried to delete the export bucket by first finding the id of the bucket with atlas cli:
atlas backups exports buckets list

And then attempted to delete it with:
atlas backups exports buckets delete --bucketId=<bucket_id_from_above_command_here>
However, this resulted in an error:
Error: https://cloud.mongodb.com/api/atlas/v2/groups/<project_id>/backup/exportBuckets/<bucket_id> DELETE: HTTP 400 (Error code: “EXPORT_BUCKET_DELETE_FAILED”) Detail: Failed to delete export Bucket with ID <bucket_id>. Reason: Bad Request. Params: [<bucket_id>]

I’ve tried authenticating to atlas cli with api keys with Organization Owner and Project Owner permissions

So my question is:

How do I actually remove an export bucket without destroying my cluster?

I’ve now also tried the Atlas Administration API by successfully authenticating with the auth digest header, fetching export buckets with this
https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Cloud-Backups/operation/listExportBuckets

and tried to delete the export bucket association with
https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Cloud-Backups/operation/deleteExportBucket

which gives me the following json error:

{
    "detail": "Failed to delete export Bucket with ID <bucket_id>.",
    "error": 400,
    "errorCode": "EXPORT_BUCKET_DELETE_FAILED",
    "parameters": [
        "<bucket_id>"
    ],
    "reason": "Bad Request"
}

I’m at a loss of what to do next, as destroying the cluster is not an option-

Hi Mika,

What was the output here? Redact the "_id" and "iamRoleId" values within the results array.

Can you provide the full command here used? Include a replacement / dummy value for "exportBucketId" or be sure to redact the actual value used before posting here.

Regards,
Jason

What was the output here? Redact the "_id" and "iamRoleId" values within the results array.

{
    "links": [
        {
            "href": "https://cloud.mongodb.com/api/atlas/v2/groups/<our_project_id>/backup/exportBuckets?pageNum=1&itemsPerPage=100",
            "rel": "self"
        }
    ],
    "results": [
        {
            "_id": <bucket_id_1>",
            "bucketName": "<bucket_name_1>",
            "cloudProvider": "AWS",
            "iamRoleId": "<role_1_id>"
        },
        {
            "_id": "<bucket_id_2>",
            "bucketName": "taika3d-backups-mongodb-snapshots",
            "cloudProvider": "AWS",
            "iamRoleId": "<role_2_id>"
        }
    ],
    "totalCount": 2
}

I have to redact more than your suggested redactions since this is a public forum and bucket names would expose information that I’m not allowed to share publicly

atlas backup exports buckets delete --bucketId=<bucket_2_id>

I used the “bucket_2_id” value from the API response

I also tried the admin API with HTTP DELETE method

[https://cloud.mongodb.com/api/atlas/v2/groups/<our_project_id>/backup/exportBuckets/<bucket_2_id>

Which resulted in the following response:

{
    "detail": "Failed to delete export Bucket with ID <bucket_2_id.",
    "error": 400,
    "errorCode": "EXPORT_BUCKET_DELETE_FAILED",
    "parameters": [
        "<bucket_2_id>"
    ],
    "reason": "Bad Request"
}

The atlas cli command

atlas backup exports buckets describe --bucketId=<bucket_2_id>

Correctly returns the same information about the bucket as admin API GET request earlier in this post