Skip to content

Commit

Permalink
azurerm_cosmosdb_account - support new version of `mongo_server_ver…
Browse files Browse the repository at this point in the history
…sion` (#27763)

* support new values of mongo_server_version

* fix comments

* update test case
  • Loading branch information
sinbai authored Oct 29, 2024
1 parent 1b14028 commit 8ae8bc8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 14 deletions.
13 changes: 4 additions & 9 deletions internal/services/cosmos/cosmosdb_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,10 @@ func resourceCosmosDbAccount() *pluginsdk.Resource {
},

"mongo_server_version": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(cosmosdb.ServerVersionThreePointTwo),
string(cosmosdb.ServerVersionThreePointSix),
string(cosmosdb.ServerVersionFourPointZero),
string(cosmosdb.ServerVersionFourPointTwo),
}, false),
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice(cosmosdb.PossibleValuesForServerVersion(), false),
},

"multiple_write_locations_enabled": {
Expand Down
53 changes: 49 additions & 4 deletions internal/services/cosmos/cosmosdb_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,52 @@ func TestAccCosmosDBAccount_mongoVersion42(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicMongoDBVersion42(data, cosmosdb.DefaultConsistencyLevelSession),
Config: r.basicMongoDBVersion(data, cosmosdb.DefaultConsistencyLevelSession, "4.2"),
Check: acceptance.ComposeAggregateTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccCosmosDBAccount_mongoVersion50(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_cosmosdb_account", "test")
r := CosmosDBAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicMongoDBVersion(data, cosmosdb.DefaultConsistencyLevelStrong, "5.0"),
Check: acceptance.ComposeAggregateTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccCosmosDBAccount_mongoVersion60(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_cosmosdb_account", "test")
r := CosmosDBAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicMongoDBVersion(data, cosmosdb.DefaultConsistencyLevelSession, "6.0"),
Check: acceptance.ComposeAggregateTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccCosmosDBAccount_mongoVersion70(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_cosmosdb_account", "test")
r := CosmosDBAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicMongoDBVersion(data, cosmosdb.DefaultConsistencyLevelSession, "7.0"),
Check: acceptance.ComposeAggregateTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -3942,7 +3987,7 @@ resource "azurerm_cosmosdb_account" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, string(consistency))
}

func (CosmosDBAccountResource) basicMongoDBVersion42(data acceptance.TestData, consistency cosmosdb.DefaultConsistencyLevel) string {
func (CosmosDBAccountResource) basicMongoDBVersion(data acceptance.TestData, consistency cosmosdb.DefaultConsistencyLevel, version string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -3959,7 +4004,7 @@ resource "azurerm_cosmosdb_account" "test" {
resource_group_name = azurerm_resource_group.test.name
offer_type = "Standard"
kind = "MongoDB"
mongo_server_version = "4.2"
mongo_server_version = "%s"
capabilities {
name = "EnableMongo"
Expand All @@ -3974,7 +4019,7 @@ resource "azurerm_cosmosdb_account" "test" {
failover_priority = 0
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, string(consistency))
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, version, string(consistency))
}

func (CosmosDBAccountResource) basicWithLocalAuthenticationDisabled(data acceptance.TestData, kind cosmosdb.DatabaseAccountKind, consistency cosmosdb.DefaultConsistencyLevel) string {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cosmosdb_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ The following arguments are supported:

* `access_key_metadata_writes_enabled` - (Optional) Is write operations on metadata resources (databases, containers, throughput) via account keys enabled? Defaults to `true`.

* `mongo_server_version` - (Optional) The Server Version of a MongoDB account. Possible values are `4.2`, `4.0`, `3.6`, and `3.2`.
* `mongo_server_version` - (Optional) The Server Version of a MongoDB account. Possible values are `7.0`, `6.0`, `5.0`, `4.2`, `4.0`, `3.6`, and `3.2`.

* `network_acl_bypass_for_azure_services` - (Optional) If Azure services can bypass ACLs. Defaults to `false`.

Expand Down

0 comments on commit 8ae8bc8

Please sign in to comment.