terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

Support for MongoDB API versions 5.0 and 6.0

Open ipock opened this issue 9 months ago • 13 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Description

Microsoft now supports running MongoDB API versions 5.0 and 6.0. Currently, these two version numbers cause a validation error when specified in the mongo_server_version variable on the azure_cosmosdb_account resource provider. The resource provider should be updated to reflect the newly available versions.

New or Affected Resource(s)/Data Source(s)

azurerm_cosmosdb_account

Potential Terraform Configuration

resource "azurerm_cosmosdb_account" "mongodb" {

  name                          = "${var.prefix}-mongodb-acct"
  resource_group_name           = var.resource_group_name
  location                      = var.location
  offer_type                    = "Standard"
  kind                          = "MongoDB"
  public_network_access_enabled = false
  enable_automatic_failover     = true
  mongo_server_version          = "5.0" # or 6.0

# remainder of resource settings follow

}

References

Support for MongoDB API 5.0: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/feature-support-50

Support for MongoDB API 6.0: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/feature-support-60

ipock avatar May 07 '24 15:05 ipock

Thanks for raising this issue. This new version hasn't been released to Swagger. Once Service API supports it, we will take another look.

neil-yechenwei avatar May 08 '24 08:05 neil-yechenwei

A temporary workaround that worked for me is manually setting the version to 6.0 in Azure Portal (Features > Update MongoDB server version) and removing the mongo_server_version variable.

ryanhuang365 avatar May 21 '24 14:05 ryanhuang365

Hi @neil-yechenwei, can you re-evaluate? The versions 5.0 and 6.0 are now clearly present in the stable API: https://github.com/Azure/azure-rest-api-specs/blob/32f566eb38af9593cfc1ed183362471c50d67fb2/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-05-15/cosmos-db.json#L9617

jvalteren avatar Jun 05 '24 15:06 jvalteren

Any news? @neil-yechenwei

dv0gt avatar Jun 11 '24 10:06 dv0gt

@dv0gt @jvalteren it's worth noting that the API Version isn't fully deployed yet:

$ az rest --method get --url "https://management.azure.com/subscriptions/XXX/providers/Microsoft.DocumentDB?api-version=2024-05-15" Bad Request({"error":{"code":"InvalidApiVersionParameter","message":"The api-version '2024-05-15' is invalid. The supported versions are '2024-03-01,2023-07-01,2023-07-01-preview,2023-03-01-preview,2022-12-01,2022-11-01-preview,2022-09-01,2022-06-01,2022-05-01,2022-03-01-preview,2022-01-01,2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."}})

Unfortunately just because the API Definition exists within Azure/azure-rest-api-specs doesn't mean it's available for use - and it's worth noting that some service teams write the API Definitions first, whilst others deploy the API then publish the associated API Definition, so the canonical source remains the versions returned from the Azure API.

All of which is to say, unfortunately this remains blocked until the API is deployed (in multiple regions) - right now only the API definition is available.

tombuildsstuff avatar Jun 11 '24 11:06 tombuildsstuff

Thanks @tombuildsstuff, that is good to know (and unexpected).

Do you know of any status page or other information source where these things can be tracked? I didn't expect to find myself at 'the cutting edge' of Azure infrastructure development with these simple things.

Migration of a hosting project with relatively low complexity has required way more effort than expected because of little issues like this. It would greatly help predictability and thus planning if there would be more transparency on changes in API (preview status, availability etc).

jvalteren avatar Jun 13 '24 08:06 jvalteren

Any ETA on when this will be available?

@jvalteren this can help https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/change-log or https://azure.microsoft.com/en-gb/updates/.

Microsoft is never super clear when they will release things like this unfortunately.

ferronsw avatar Jun 25 '24 13:06 ferronsw

Cosmos DB also supports MongoDB API v7.0

EpicWink avatar Aug 15 '24 04:08 EpicWink

The version can be changed using the azapi, the following worked for me to deploy version 6


resource "azurerm_resource_group" "example" {
  name     = "democosmos"
  location = "westus2"
}

resource "azurerm_cosmosdb_account" "db" {
  name                 = "stephitest"
  location             = azurerm_resource_group.example.location
  resource_group_name  = azurerm_resource_group.example.name
  offer_type           = "Standard"
  kind                 = "MongoDB"
  mongo_server_version = "4.2"

  automatic_failover_enabled = false


  capabilities {
    name = "EnableServerless"
  }

  capabilities {
    name = "EnableMongo"
  }

  consistency_policy {
    consistency_level       = "Session"
    max_interval_in_seconds = 5
    max_staleness_prefix    = 100
  }

  geo_location {
    failover_priority = 0
    location          = "westus2"
  }
  lifecycle {
    ignore_changes = [ mongo_server_version ]
  }
}


provider "azapi" {
  subscription_id = var.subscription_id
}

resource "azapi_update_resource" "update" {
  resource_id = azurerm_cosmosdb_account.db.id
  type = "Microsoft.DocumentDB/databaseAccounts@2024-05-15"
  body = {
    properties = {
        apiProperties = {
            serverVersion = "6.0"
        }
    }
  }
}



steph409 avatar Sep 04 '24 14:09 steph409

The code limiting mongo_server_version to version 3.2, 3.6, 4.0 and 4.2 seem to be here (just supplying for reference): https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/cosmos/cosmosdb_account_resource.go#L482

This is the commit where 4.2 was added: https://github.com/hashicorp/terraform-provider-azurerm/pull/16738/commits/1f9a6f64ec89f68e677c17f18a9736fdcfb688bb

anton-x-t avatar Sep 10 '24 10:09 anton-x-t

Any news on this?

svaraksin-gd avatar Oct 02 '24 18:10 svaraksin-gd

Any updates?

ManuelAngel99 avatar Oct 06 '24 12:10 ManuelAngel99

Hello, any updates on this?

Kortex avatar Oct 06 '24 23:10 Kortex