Add azurerm_cosmosdb_fleet resource#31546
Add azurerm_cosmosdb_fleet resource#31546v-yhyeo0202 wants to merge 14 commits intohashicorp:mainfrom
azurerm_cosmosdb_fleet resource#31546Conversation
703523b to
99bb218
Compare
azurerm_cosmosdb_fleets resourceazurerm_cosmosdb_fleet resource
|
@v-yhyeo0202 Thanks for working on this. When do you expect this to be merged? |
|
@saikrishna397 due to the large number of PRs and shortage of reviewers, I cannot be sure when will this PR be merged. Meanwhile you may try to use azapi_resource to create the resource. Let me know if you face any issues when applying the workaround. |
|
Hello @v-yhyeo0202 and @gerrytan. I want to check how the review of this PR going and if you have any updates on ETA on when it will be merged as I see it was requested for review 3 weeks ago? |
| ) | ||
|
|
||
| func FleetName(v interface{}, k string) (warnings []string, errors []error) { | ||
| name := v.(string) |
There was a problem hiding this comment.
Put the link as a comment, so other people will know where those restrictions are from.
gerrytan
left a comment
There was a problem hiding this comment.
Thanks @v-yhyeo0202, I left comments on few area of concerns.
Also I note that there are child / releated resources that have to be implemented in a separate PR:
|
|
||
| resource "azurerm_cosmosdb_fleet" "example" { | ||
| name = "fleet-test" | ||
| resource_group_name = "azurerm_resource_group.example.name" |
There was a problem hiding this comment.
Wrong RG name syntax. Remove the quote.
| resource_group_name = "azurerm_resource_group.example.name" | |
| resource_group_name = azurerm_resource_group.example.name |
Same problem with location below
There was a problem hiding this comment.
Thanks @gerrytan for the review. The issue is fixed accordingly. Let me know if I have to work on the related resources.
|
|
||
| The following arguments are supported: | ||
|
|
||
| * `location` - (Required) The Azure Region where the Cosmos DB Fleets should exist. Changing this forces new Cosmos DB Fleets to be created. |
There was a problem hiding this comment.
Please follow the ordering described in reference-documentation-standards.md, part of id (name and resource_group_name) has to be ordered at the top. Please apply this to the schema arguments and other parts of the code too.
| layout: "azurerm" | ||
| page_title: "Azure Resource Manager: azurerm_cosmosdb_fleet" | ||
| description: |- | ||
| Manages a Cosmos DB Fleets. |
There was a problem hiding this comment.
Use singular Fleet instead of plural Fleets. Please change other places too.
| } | ||
|
|
||
| func (CosmosDbFleetResource) ModelObject() interface{} { | ||
| return &CosmosDbFleetResource{} |
There was a problem hiding this comment.
This should return the Model, not the resource. Please have a look at the example in guide-new-resource.md
| "tags": { | ||
| Type: schema.TypeMap, | ||
| Optional: true, | ||
| // `ForceNew` behavior is added as `tags` property is absent in update model |
There was a problem hiding this comment.
The "Create" SDK method uses PUT HTTP method, can you please check if we can use this for update?
There was a problem hiding this comment.
By applying a typical Update method and test which involves only change in Tags property, an error occurs mentioning that it is unable to create a resource with same ID. Following are the REST API request and response.
Request body before update
{
"location": "southeastasia",
"tags": null
}Request body during update
{
"id": "/subscriptions/REDACTED/resourceGroups/REDACTED/providers/Microsoft.DocumentDB/fleets/REDACTED",
"location": "Southeast Asia",
"name": "REDACTED",
"properties": {
"provisioningState": "Succeeded"
},
"tags": {
"env": "test"
},
"type": "Microsoft.DocumentDB/fleets"
}Error from response body during update
{
"code": "BadRequest",
"message": "Exception occurred trying to create Fleet with Name: REDACTED and SubscriptionID: REDACTED, Message: Entity with the specified id already exists in the system.\r\nActivityId: REDACTED, Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Documents.Common/2.14.0"
}There was a problem hiding this comment.
Update FleetPool use PATCH - see details here: https://learn.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/fleet/update?view=rest-cosmos-db-resource-provider-2025-10-15&tabs=HTTP
There was a problem hiding this comment.
But that is not useful @sesmyrnov , the only updatable property (tags) is not supported by that PATCH API.
|
|
||
| func (r Registration) Resources() []sdk.Resource { | ||
| return []sdk.Resource{ | ||
| CosmosDbFleetResource{}, |
There was a problem hiding this comment.
This has to be sorted alphabetically. Please run azurerm-linter and check violations.
There was a problem hiding this comment.
Thank you @v-yhyeo0202 this PR looks good to me.
Thanks for addressing all the feedbacks and rerunning the acctests.
Please do not close the linked issue yet and do the (child / related?) resources as a follow up work in a separate PR (1 resource per PR). This resource is only a container and not useful by itself.
I assume we also need azurerm_cosmosdb_fleet_space and azurerm_cosmosdb_fleet_database_account as a minimum. @sesmyrnov can you help confirm this for us?

Community Note
Description
azurerm_cosmosdb_fleetresource is added in this PR. The related sources are listed below:Azure REST API specification
https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/DocumentDB/stable/2025-10-15/fleet.json
Documentation
https://learn.microsoft.com/en-us/azure/cosmos-db/fleet
PR Checklist
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
(For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.Testing
https://hashicorp.teamcity.com/buildConfiguration/TF_AzureRM_AZURERM_SERVICE_PUBLIC_COSMOS/652361?buildTab=overview

Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_cosmosdb_fleet- add resourceThis is a (please select all that apply):
Related Issue(s)
Fixes #31243
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.