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]: Error: Provider produced inconsistent result after apply - .region_usage_restrictions: was null, but now cty.StringVal("COMMERCIAL_FEDRAMP_REGIONS_ONLY") #2263

Closed Patrick-Catenzaro closed 1 month ago

Patrick-Catenzaro commented 1 month ago

Is there an existing issue for this?

Provider Version

1.16.0

Terraform Version

1.2.3

Terraform Edition

Terraform Open Source (OSS)

Current Behavior

Terraform applies are failing for projects in the MongoDB Atlas for Government instance after a recent change to the provider. Terraform starts the apply and then complains that "Error: Provider produced inconsistent result after apply". This is only effecting MongoDB Atlas for Government projects at this time. We even tried removing the project resource from the Terraform State file and then importing it back and the same behavior was seen.

resource/mongodbatlas_project: Reads region_usage_restrictions attribute value from get request (https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2104)

Terraform configuration to reproduce the issue

provider "mongodbatlas" {
  public_key          = var.mongodb_atlas_api_pub_key
  private_key         = var.mongodb_atlas_api_pri_key
  is_mongodbgov_cloud = true
}

resource "mongodbatlas_project" "project" {
  count                        = var.enabled ? 1 : 0
  name                         = local.project_name
  org_id                       = var.mongodb_atlas_org_id
  is_data_explorer_enabled     = true
  with_default_alerts_settings = false

}

Steps To Reproduce

  1. Create a project with a version of the provider older than 1.16.0 ex: 1.15.3
  2. Upgrade the provider to 1.16.0
  3. Run a Terraform apply with the changed provider
  4. Issue will appear after the apply completes

Logs

Error: Provider produced inconsistent result after apply
When applying changes to module.mongodb_project.mongodbatlas_project.project[0], provider "module.mongodb_project.provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" produced an unexpected new value: .region_usage_restrictions: was null, but now cty.StringVal("COMMERCIAL_FEDRAMP_REGIONS_ONLY"). 
This is a bug in the provider, which should be reported in the provider's own issue tracker.

Code of Conduct

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

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

marcosuma commented 1 month ago

Hi @Patrick-Catenzaro, thanks for opening this issue with us. From a quick look I had, it looks like this change might be causing the inconsistency you found out during the upgrade (cc @maastha). While this is just an hypothesis, have you tried of setting the value of region_usage_restrictions to COMMERCIAL_FEDRAMP_REGIONS_ONLY in your script?

While that might not be ideal, it could help you unblock this problem. In any case, if this upgrade bug is confirmed, we should release a fix.

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