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]: Unable to recreate IP access list entries after UI modifications #2343

Closed nick-augustine closed 16 hours ago

nick-augustine commented 2 weeks ago

Is there an existing issue for this?

Provider Version

1.17.0

Terraform Version

1.8.3

Terraform Edition

Terraform Cloud

Current Behavior

When a resource mongodbatlas_project_ip_access_list is removed from the list of networks in the Mongo Cloud UI, we're expecting Terraform to be used to create that again or remove and create new entries during terraform applies. The current behavior of this resource will generate an error when attempting to read the state during a terraform plan -

│ Error: resource not found
│ 
│   with module.dev_project.mongodbatlas_project_ip_access_list.default["170.85.0.0/16"],
│   on ../modules/mongo_project/networking.tf line 2, in resource "mongodbatlas_project_ip_access_list" "default":
│    2: resource "mongodbatlas_project_ip_access_list" "default" {
│ 
│ https://cloud.mongodb.com/api/atlas/v2/groups/66574f0e56a8133612676008/accessList/170.85.0.0%2F16
│ GET: HTTP 404 Not Found (Error code:
│ "ATLAS_NETWORK_PERMISSION_ENTRY_NOT_FOUND") Detail: IP Address
│ 170.85.0.0/16 not on Atlas access list for group 66574f0e56a8133612676008.
│ Reason: Not Found. Params: [170.85.0.0/16 66574f0e56a8133612676008]
╵
Operation failed: failed running terraform plan (exit 1)

If the resource is removed from terraform state, the plan will successfully run. terraform state rm 'module.dev_project.mongodbatlas_project_ip_access_list.default["170.85.0.0/16"]'

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.dev_project.mongodbatlas_project_ip_access_list.deafult_sw["170.85.0.0/16"] will be created
  + resource "mongodbatlas_project_ip_access_list" "deafult_sw" {
      + aws_security_group = (known after apply)
      + cidr_block         = "170.85.0.0/16"
      + comment            = "Default Set of SW Networks including ZScaler"
      + id                 = (known after apply)
      + ip_address         = (known after apply)
      + project_id         = "66574f0e56a8133612676008"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Terraform configuration to reproduce the issue

# Terraform code being used within a module 
resource "mongodbatlas_project_ip_access_list" "default" {
  for_each = var.default_networks_whitelist

  project_id = mongodbatlas_project.this.id
  cidr_block = each.value
  comment    = "Default Set of Networks"
}

variable "default_networks_whitelist" {
  type    = set(string)
  default = ["8.8.8.8", "1.1.1.1", "192.168.1.1", "170.85.0.0/16"]
}

Steps To Reproduce

  1. Create resource mongodbatlas_project_ip_access_list with Terraform code
  2. From the Mongo Cloud UI, remove the resource from the project.
  3. Attempt to terraform plan to recreate the resource.

Logs

No response

Code of Conduct

github-actions[bot] commented 2 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-253876 was created for internal tracking.

maastha commented 2 weeks ago

@nick-augustine Thank you for creating this issue! I was able to reproduce this issue. We are working on the fix for this issue which should be available in our next release.

github-actions[bot] commented 1 week 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!

nick-augustine commented 1 week ago

bump

github-actions[bot] commented 2 days 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!

EspenAlbert commented 16 hours ago

Looks like this has been fixed in #2349 and released in 1.17.2.