Skip to content

Commit

Permalink
Create MongoDB v3.6 with azurerm_cosmosdb_account (#4757) (#5325)
Browse files Browse the repository at this point in the history
Fixes #4757 for service/cosmosdb
  • Loading branch information
aristosvo authored and katbyte committed Jan 20, 2020
1 parent 51df4e9 commit c3a9874
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func resourceArmCosmosDbAccount() *schema.Resource {
"EnableTable",
"EnableGremlin",
"EnableCassandra",
"EnableMongo",
"EnableAggregationPipeline",
"MongoDBv3.4",
"mongoEnableDocLevelTTL",
Expand Down Expand Up @@ -397,21 +398,6 @@ func resourceArmCosmosDbAccountCreate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error creating CosmosDB Account %q (Resource Group %q): %+v", name, resourceGroup, err)
}

//for some reason capabilities doesn't always work on create, so lets patch it
//tracked: https://github.com/Azure/azure-sdk-for-go/issues/2864
future, err := client.Patch(ctx, resourceGroup, name, documentdb.DatabaseAccountPatchParameters{
DatabaseAccountPatchProperties: &documentdb.DatabaseAccountPatchProperties{
Capabilities: account.Capabilities,
},
})
if err != nil {
return fmt.Errorf("Error Patching CosmosDB Account %q (Resource Group %q): %+v", name, resourceGroup, err)
}

if err := future.WaitForCompletionRef(context.Background(), client.Client); err != nil {
return fmt.Errorf("Error waiting on patch future CosmosDB Account %q (Resource Group %q): %+v", name, resourceGroup, err)
}

id := resp.ID
if id == nil {
return fmt.Errorf("Cannot read CosmosDB Account '%s' (resource group %s) ID", name, resourceGroup)
Expand Down Expand Up @@ -550,21 +536,6 @@ func resourceArmCosmosDbAccountUpdate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Cannot read CosmosDB Account '%s' (resource group %s) ID", name, resourceGroup)
}

//for some reason capabilities doesn't always work on create, so lets patch it
//tracked: https://github.com/Azure/azure-sdk-for-go/issues/2864
future, err := client.Patch(ctx, resourceGroup, name, documentdb.DatabaseAccountPatchParameters{
DatabaseAccountPatchProperties: &documentdb.DatabaseAccountPatchProperties{
Capabilities: account.Capabilities,
},
})
if err != nil {
return fmt.Errorf("Error Patching CosmosDB Account %q (Resource Group %q): %+v", name, resourceGroup, err)
}

if err := future.WaitForCompletionRef(context.Background(), client.Client); err != nil {
return fmt.Errorf("Error waiting on patch future CosmosDB Account %q (Resource Group %q): %+v", name, resourceGroup, err)
}

d.SetId(*id)

return resourceArmCosmosDbAccountRead(d, meta)
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 @@ -99,7 +99,7 @@ The following arguments are supported:

`capabilities` Configures the capabilities to enable for this Cosmos DB account:

* `name` - (Required) The capability to enable - Possible values are `EnableAggregationPipeline`, `EnableCassandra`, `EnableGremlin`, `EnableTable`, `MongoDBv3.4`, and `mongoEnableDocLevelTTL`.
* `name` - (Required) The capability to enable - Possible values are `EnableAggregationPipeline`, `EnableCassandra`, `EnableGremlin`,`EnableMongo`, `EnableTable`, `MongoDBv3.4`, and `mongoEnableDocLevelTTL`.

**NOTE:** The `prefix` and `failover_priority` fields of a location cannot be changed for the location with a failover priority of `0`.

Expand Down

1 comment on commit c3a9874

@librannk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update documentation for the same, EnableMongo is missing from the documentation of cosmosdb account.

Please sign in to comment.