hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

azurerm_cosmosdb_account: Removing "MongoDBv3.4" capability forces recreate with mongo_server_version="4.0" #18493

Open markbangert opened 2 years ago

markbangert commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.1.5

AzureRM Provider Version

3.23.0

Affected Resource(s)/Data Source(s)

azurerm_cosmosdb_account

Terraform Configuration Files

resource "azurerm_cosmosdb_account" "cdb" {
  name                = local.cosmos_database_account
  resource_group_name = local.resource_group_name
  location            = local.location
  offer_type          = "Standard"
  kind                = "MongoDB"
  mongo_server_version = "4.0"
...

+++ Removing the following capability forces recreate +++
  capabilities {
    name = "MongoDBv3.4"
  }
+++
...
}

Debug Output/Panic Output

- capabilities { # forces replacement
          - name = "MongoDBv3.4" -> null
        }

Expected Behaviour

We are maintaining a Cosmos DB resource with TF. Currently we are running on Mongo Server Version 4.0. For whatever reason we also specified the capability "MongoDBv3.4" within our configuration. I would expect that I can savely remove the capability to run the earlier version 3.4 from the configuration but running the terraform plan states that this would result in a recreation of our DB.

Actual Behaviour

Removing the capability "MongoDBv3.4" from a azurerm_cosmosdb_account running Mongo Server Version 4.0 forces a recreate of the Cosmos DB according to TF plan.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

sinbai commented 2 years ago

@markbangert thanks for opening this issue. As far as I know, once the MongoDBv3.4 is set up, it could not be removed by Azure API. Please correct me if I were wrong. Per the tf doc, changing capabilities forces a new resource to be created, so this is by design.

markbangert commented 2 years ago

Thank you for your kind reply. Can you further clarify what the MongoDbv3.4 capability actually means for the resource? I understand that the property

mongo_server_version = "4.0"

controls the API version. What does this capability do? Does this mean I can use both API versions, 4.0 and 3.4?

nick4fake commented 1 week ago

It's confusing that there is literally exactly zero documentation on what MongoDBv3.4 capability does