Skip to content

Add azurerm_cosmosdb_fleet resource#31546

Draft
v-yhyeo0202 wants to merge 14 commits intohashicorp:mainfrom
v-yhyeo0202:add-cosmosdb-fleets
Draft

Add azurerm_cosmosdb_fleet resource#31546
v-yhyeo0202 wants to merge 14 commits intohashicorp:mainfrom
v-yhyeo0202:add-cosmosdb-fleets

Conversation

@v-yhyeo0202
Copy link
Copy Markdown
Collaborator

@v-yhyeo0202 v-yhyeo0202 commented Jan 21, 2026

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

azurerm_cosmosdb_fleet resource 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

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

https://hashicorp.teamcity.com/buildConfiguration/TF_AzureRM_AZURERM_SERVICE_PUBLIC_COSMOS/652361?buildTab=overview
image

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_cosmosdb_fleet - add resource

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

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.

@v-yhyeo0202 v-yhyeo0202 changed the title Add azurerm_cosmosdb_fleets resource Add azurerm_cosmosdb_fleet resource Feb 10, 2026
@saikrishna397
Copy link
Copy Markdown

@v-yhyeo0202 Thanks for working on this. When do you expect this to be merged?

@v-yhyeo0202 v-yhyeo0202 requested a review from gerrytan March 26, 2026 00:49
@v-yhyeo0202
Copy link
Copy Markdown
Collaborator Author

@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.

@sesmyrnov
Copy link
Copy Markdown

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?
( we have several Azure Cosmos DB customers inquiring on the supportability of Fleet feature and not ready to commit to use azapi workaround.)

)

func FleetName(v interface{}, k string) (warnings []string, errors []error) {
name := v.(string)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Put the link as a comment, so other people will know where those restrictions are from.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Collaborator

@gerrytan gerrytan left a comment

Choose a reason for hiding this comment

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

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:

Image


resource "azurerm_cosmosdb_fleet" "example" {
name = "fleet-test"
resource_group_name = "azurerm_resource_group.example.name"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wrong RG name syntax. Remove the quote.

Suggested change
resource_group_name = "azurerm_resource_group.example.name"
resource_group_name = azurerm_resource_group.example.name

Same problem with location below

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_cosmosdb_fleet"
description: |-
Manages a Cosmos DB Fleets.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use singular Fleet instead of plural Fleets. Please change other places too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

}

func (CosmosDbFleetResource) ModelObject() interface{} {
return &CosmosDbFleetResource{}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should return the Model, not the resource. Please have a look at the example in guide-new-resource.md

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

"tags": {
Type: schema.TypeMap,
Optional: true,
// `ForceNew` behavior is added as `tags` property is absent in update model
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The "Create" SDK method uses PUT HTTP method, can you please check if we can use this for update?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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{},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This has to be sorted alphabetically. Please run azurerm-linter and check violations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@v-yhyeo0202
Copy link
Copy Markdown
Collaborator Author

v-yhyeo0202 commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

@gerrytan gerrytan left a comment

Choose a reason for hiding this comment

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

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?

@sesmyrnov

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for Cosmos DB Fleet Resource

7 participants