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
240 stars 168 forks source link

terraform plan and apply fails after upgrading this module to 0.5.0 #200

Closed borfig closed 4 years ago

borfig commented 4 years ago

I have a MongoDB cluster managed with Terraform, with no backup enabled:

resource "mongodbatlas_cluster" "this" {
  project_id                   = "<project-id>"
  provider_name                = "AWS"
  provider_region_name         = "US-EAST-1"
  name                         = "MyCluster"
  provider_instance_size_name  = "M10"
  auto_scaling_disk_gb_enabled = true
  backup_enabled               = false
  mongo_db_major_version       = "4.2"
}

The cluster was created using an earlier version of this module, but when running plan or apply with the new version, I get:

Error: error getting a Cloud Provider Snapshot Backup Policy for the cluster(MyCluster): GET https://cloud.mongodb.com/api/atlas/v1.0/groups/<project-id>/clusters/MyCluster/backup/schedule: 404 (request "Not Found") No backup configuration exists for cluster <cluster-id> in group <project-id>.

It appears that relevant API returns HTTP 404 if no cloud provider snapshots are available, which will be also the case when I would decide to add a cloud provider snapshot later.

My current work-around is not to upgrade to the new version.

themantissa commented 4 years ago

Ack'ed @borfig - pinging the developers now for triage.

PacoDw commented 4 years ago

Hello, @borfig I tried to recreate the issue creating the above TF configuration cluster and later switching to the new version and do terraform plan and I didn't get any error, what's the TF version are you using? Also, could you share your log? you can use the following command: TF_LOG=DEBUG terraform plan |& tee log.txt

themantissa commented 4 years ago

@borfig (@dordadush @alonkol - who also ack'ed the report) - if one of you who is having the error can provide the requested details from PacoDW above, that will help us a great deal.

borfig commented 4 years ago

I am using Terraform v0.12.23 Here is the relevant grep plugin.terraform-provider-mongodbatlas output (our Terraform file is huge...) mongodbatlas.txt

PacoDw commented 4 years ago

@borfig I made a small change to fix that you can see the details on the PR #203 , also could you test it to check if it works fine for you?

Let me know if the issue persists or you have another comment or concern.

borfig commented 4 years ago

@PacoDw the proposed fix works in my case

PacoDw commented 4 years ago

@borfig I'm happy to hear that, thank you so much for all :)

themantissa commented 4 years ago

@borfig per your comment "It appears that relevant API returns HTTP 404 if no cloud provider snapshots are available, which will be also the case when I would decide to add a cloud provider snapshot later." The later part of the statement is not true, if you add cloud provider backup later you automatically get a default policy (see the underlying API here - only a GET/PATCH - https://docs.atlas.mongodb.com/reference/api/snapshot-schedule/). This made this a particularly tricky resources to bring into terraform.

Thank you for working w/ us to resolve this!

borfig commented 4 years ago

@themantissa regarding my comment - if I decide to use Cloud Provider Snapshots via Terraform:

Both options are not ideal...

@PacoDw you are welcome

shekar0523 commented 4 years ago

@PacoDw @themantissa I got the same error with the Azure provider. Here are the list of provider verisons Terraform v0.12.24

It is working fine if I set flag backup_enabled = true. If it is false the it is throwing an error message

themantissa commented 4 years ago

@shekar0523 thank you - the fix we have should correct this as well and will be out in a hotfix 0.5.1 soon.

shekar0523 commented 4 years ago

@themantissa Do you know when we can expect to get that hotfix to release ?

themantissa commented 4 years ago

@shekar0523 it released yesterday. I'll close this ticket shortly.

PacoDw commented 4 years ago

Hello, @shekar0523 I tested with the new release with your shared TF configuration, and I didn't get any errors :)

themantissa commented 4 years ago

@borfig back to your comment -

if I decide to use Cloud Provider Snapshots via Terraform: with the previous version of the module, I would have to use null_resource-based provisioning with the 0.5.0 version of the module, in order to run plan or apply I have to enable cloud provider backups manually via API or Console.

This is not quite the case if I understand what you are saying. The way this was spec'ed one just needs to set the variable for cloud provider snapshots in the config to true and that will enable them and, basically, import the initial schedule that is automatically created and if you want to modify it you can by creating a resource for that. Otherwise it uses the default.

themantissa commented 4 years ago

0.5.1 corrects this issue but feel free to reach out if any questions remain. Thank you all.