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

fix: Marks `project.region_usage_restrictions` as OptionalComputed to avoid provider upgrade errors #2291

Closed EspenAlbert closed 1 month ago

EspenAlbert commented 1 month ago

Description

Link to any related issue(s): #2263 and CLOUDP-248517

Marking the attribute as Computed as earlier versions of the resource will have an empty state for this attribute. Since the state is empty and the default server value depends on cloud-gov or not:

Example of error and solution:

mongodbatlas_project.project: Modifying... [id=664c6820c4391e7c9f58377c]
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to mongodbatlas_project.project, provider "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.
╵

After adding Computed: true

mongodbatlas_project.project: Refreshing state... [id=664c6820c4391e7c9f58377c]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Type of change:

Required Checklist:

Further comments

marcosuma commented 1 month ago

do we have an acceptance test for this?

EspenAlbert commented 1 month ago

@marcosuma I have been investigating a bit, and we don't have ANY test running in mongodbgov. I am looking at ways to add those tests

github-actions[bot] commented 1 month ago

APIx bot: a message has been sent to Docs Slack channel

marcosuma commented 1 month ago

Nice one!