terraform-provider-mongodbatlas: `error deleting MongoDB Network Peering Container`, even though Container exists

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.0.8
on darwin_amd64

Your version of Terraform is out of date! The latest version
is 1.0.11. You can update by downloading from https://www.terraform.io/downloads.html

Provider version 1.0.2

Steps to Reproduce

  1. Create network container in an existing project, with no clusters in it
  2. Create cluster
  3. Delete cluster
  4. Delete network container -> fails

Debug Output

Ok, so I’ve been coping with this issue for a while and I thought I had fixed it by setting a simple timer between resources, but it resurfaced again even then. It seems strange because, when trying to destroy the network container, the provider is complaining that the network container doesn’t exist, even though it does:

module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 4m10s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 4m20s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 4m30s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 4m40s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 4m50s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 5m0s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 5m10s elapsed]
module.mongodb_atlas_aws[0].mongodbatlas_network_container.default: Still destroying... [id=Y29udGFpbmVyX2lk:NjE3MDAzODAwMDNkMzcwMW...pZA==:NjE3MDAzNDY4ODA4YmQ2ODA5ZDdjYWE3, 5m20s elapsed]
╷
│ Error: error deleting MongoDB Network Peering Container (61700380003d3701c115dc58): couldn't find resource (21 retries)
│ 
│ 
╵

However, I went to the MongoDB Atlas Administration API, and the network container did in fact exist:

{
  "links": [
    {
      "href": "https://cloud.mongodb.com/api/atlas/v1.0/groups/REDACTED/containers/all?pageNum=1&itemsPerPage=100",
      "rel": "self"
    }
  ],
  "results": [
    {
      "atlasCidrBlock": "10.1.128.0/24",
      "id": "61700380003d3701c115dc58",
      "providerName": "AWS",
      "provisioned": true,
      "regionName": "EU_WEST_3",
      "vpcId": "REDACTED"
    }
  ],
  "totalCount": 1
}

You can check it’s the same container ID. I tried deleting it once again with TF, to no sucess (same error).

Then I tried deleting it from the API (to which I got no problems, 200 OK), and upon checking the containers list again:

{
  "links": [
    {
      "href": "https://cloud.mongodb.com/api/atlas/v1.0/groups/REDACTED/containers/all?pageNum=1&itemsPerPage=100",
      "rel": "self"
    }
  ],
  "results": [],
  "totalCount": 0
}

it was successfully deleted.

Worth noting that I’m using the same MongoDB Atlas credentials (and same organization & project ID) throughout my code. So it is not possible that the provider might be picking different project or group ID…

Additional Context

The network container that was trying to delete:

# module.mongodb_atlas_aws[0].mongodbatlas_network_container.default will be destroyed
  - resource "mongodbatlas_network_container" "default" {
      - atlas_cidr_block = "10.1.128.0/24" -> null
      - container_id     = "61700380003d3701c115dc58" -> null
      - id               = "REDACTED" -> null
      - project_id       = "REDACTED" -> null
      - provider_name    = "AWS" -> null
      - provisioned      = true -> null
      - region_name      = "EU_WEST_3" -> null
      - regions          = [] -> null
      - vpc_id           = "REDACTED" -> null
    }

My setup is quite convoluted so unfortunately I’ve not managed yet to provide a minimized reproducer. However, it might be worth investigating why this happens…? Given that (I reckon) it should be a simple DELETE HTTP method.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 21

Most upvoted comments

@nikhil-mongo

I have the same issue! We can’t delete the default network_container. We need to recreate that with other CIDR Block.

image

image

Could you help me?

Thanks!

@leynebe fyi there is another user feedback for your suggestion that you may want to upvote: https://feedback.mongodb.com/forums/924145-atlas/suggestions/39954307-cluster-termination-protection.

HI @themantissa, @nikhil-mongo, I have shared our IDs with @nikhil-mongo privately through e-mail. The issue keeps reproducing for us. Moreover, now it’s impossible to delete an existing network container, even if it doesn’t have any associated resources left.

@leynebe, as well as others - as @nikhil-mongo notes above we can look into this issue but we’d need to see it actually happening in a project - we have not been able to repro. If you can follow his guidance above to open a support case to get us the project information we can investigate this further.

I accidentally made a comment on a related but closed ticket (https://github.com/mongodb/terraform-provider-mongodbatlas/issues/88#issuecomment-1044133495) describing the same experience as @AlexRex.

Hi,

I am having the same exact problem, and I can confirm there is nothing inside the project. Just the container, same way as described by @MikiLoz92. Even though, trying to delete it through the Mongodb Atlas API yields an error:

“Cannot modify in use containers. The container still contained resources.” But there is no contained resource in it…

    {
          "atlasCidrBlock": "192.168.0.0/21",
          "id": "61e6dd473d232a08b95d680e",
          "providerName": "AWS",
          "provisioned": true,
          "regionName": "EU_WEST_3",
          "vpcId": "vpc-060b451b16db96f83"
      }

Any idea why this might be happening?

I cannot repro this at my end and everything works perfectly during creation and termination. @MikiLoz92 Once you have the logs, it will help us a lot.