Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

produced an unexpected new value: Root resource was present, but now │ absent #1160

Closed
joshworktango opened this issue May 9, 2023 · 3 comments
Assignees
Labels

Comments

@joshworktango
Copy link

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.4.6

mongodbatlas = {
      source = "mongodb/mongodbatlas"
      version = "1.9.0"
    }

Terraform Configuration File

resource "mongodbatlas_cluster" "automated_backup_test" {
    project_id   = local.project_id
    name         = "automated-backup-test"

  //Provider Settings "block"
    provider_name               = "GCP"
    provider_region_name        = "US_EAST_4"
    provider_instance_size_name = "M30"
    cloud_backup                = false   // enable cloud backup snapshots
    mongo_db_major_version       = "4.2"
    disk_size_gb = "350"
  }


  resource "mongodbatlas_cloud_backup_snapshot_restore_job" "automated_backup_test" {
    project_id      = local.project_id
    cluster_name    = mongodbatlas_cluster.automated_backup_test.name
    snapshot_id     = data.mongodbatlas_cloud_backup_snapshots.latest_snapshot.results[0].id
    delivery_type_config   {
      automated           = true
      target_cluster_name = mongodbatlas_cluster.automated_backup_test.name
      target_project_id   = local.project_id
    }
  }

data "mongodbatlas_cloud_backup_snapshots" "latest_snapshot" {
project_id = local.project_id
  cluster_name = "<>"
  page_num = 1
  items_per_page = 1
}

output "snapshot_results" {
  value = data.mongodbatlas_cloud_backup_snapshots.latest_snapshot.results[0].id
}
# Copy-paste your configuration info here

Steps to Reproduce

terraform init

terraform apply -auto-approve

Expected Behavior

Expected to fully apply which creates a cluster and restores a backup from a snapshot. Works when run manually on my local laptop

Actual Behavior

mongodbatlas_cluster.automated_backup_test: Creation complete after 16m55s
mongodbatlas_cloud_backup_snapshot_restore_job.automated_backup_test: Creating...
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to
│ mongodbatlas_cloud_backup_snapshot_restore_job.automated_backup_test,
│ provider "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]"
│ produced an unexpected new value: Root resource was present, but now
│ absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Debug Output

Crash Output

Additional Context

This is happening inside a debain docker container running on a mac M1 MBP with docker desktop. Plan is GKE on x86 but for now M1 local testing

References

@andreaangiolillo andreaangiolillo self-assigned this May 16, 2023
@andreaangiolillo
Copy link
Collaborator

Hello @joshworktango

I was able to reproduce the issue in my local environment using the provided configuration file. The issue lies in the fact that the same cluster name is being used for both the cluster_name and target_cluster_name fields in the "mongodbatlas_cloud_backup_snapshot_restore_job" resource.

To resolve this, you need to update the cluster_name field with the name of the cluster where the snapshot was taken. After making this change, the Terraform apply command should successfully apply your modifications. Here's the updated configuration:

resource "mongodbatlas_cloud_backup_snapshot_restore_job" "automated_backup_test" {
    project_id      = local.project_id
    cluster_name    = <UPDATE THIS WITH THE NAME OF THE CLUSTER USED TO TAKE THE SNAPSHOT>
    snapshot_id     = data.mongodbatlas_cloud_backup_snapshots.latest_snapshot.results[0].id
    delivery_type_config   {
      automated           = true
      target_cluster_name = mongodbatlas_cluster.automated_backup_test.name
      target_project_id   = local.project_id
    }
  }

Please let me know if you encounter any further issues.
Thanks

@Zuhairahmed
Copy link
Collaborator

@joshworktango just checking if this helps? if so feel free to close out this issue, thank you

@joshworktango
Copy link
Author

@joshworktango just checking if this helps? if so feel free to close out this issue, thank you

Hi sorry just tested this, this morning. Was off work for a few days. That seems to have resolved the issue though interesting it only happens inside the docker container not on my Mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants