Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement:] azurerm_cosmosdb_account - update the default_identity_type error message for UserAssignedIdentity #21513

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/services/cosmos/cosmosdb_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func resourceCosmosDbAccount() *pluginsdk.Resource {
Optional: true,
Computed: true,
ValidateFunc: validation.Any(
validation.StringMatch(regexp.MustCompile(`^UserAssignedIdentity(.)+$`), "It may start with `UserAssignedIdentity`"),
validation.StringMatch(regexp.MustCompile(`^UserAssignedIdentity(.)+$`), "user assigned identities must be in the format of: 'UserAssignedIdentity=/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{userAssignedIdentityName}'"),
katbyte marked this conversation as resolved.
Show resolved Hide resolved
validation.StringInSlice([]string{
"FirstPartyIdentity",
"SystemAssignedIdentity",
Expand Down
40 changes: 39 additions & 1 deletion website/docs/r/cosmosdb_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,42 @@ resource "azurerm_cosmosdb_account" "db" {
}
```

## User Assigned Identity Example Usage

```hcl
resource "azurerm_user_assigned_identity" "example" {
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
name = "example-resource"
}

resource "azurerm_cosmosdb_account" "example" {
name = "example-resource"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
default_identity_type = join("=", ["UserAssignedIdentity", azurerm_user_assigned_identity.example.id])
offer_type = "Standard"
kind = "MongoDB"

capabilities {
name = "EnableMongo"
}

consistency_policy {
consistency_level = "Strong"
}

geo_location {
location = "westus"
failover_priority = 0
}

identity {
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.example.id]
}
}
```
## Argument Reference

The following arguments are supported:
Expand All @@ -88,7 +124,9 @@ The following arguments are supported:

~> **NOTE:** `create_mode` only works when `backup.type` is `Continuous`.

* `default_identity_type` - (Optional) The default identity for accessing Key Vault. Possible values are `FirstPartyIdentity`, `SystemAssignedIdentity` or start with `UserAssignedIdentity`.
* `default_identity_type` - (Optional) The default identity for accessing Key Vault. Possible values are `FirstPartyIdentity`, `SystemAssignedIdentity` or `UserAssignedIdentity`.

~> **NOTE:** When `default_identity_type` is set to `UserAssignedIdentity` it must be in the following format: `UserAssignedIdentity=/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{userAssignedIdentityName}`.
katbyte marked this conversation as resolved.
Show resolved Hide resolved

* `kind` - (Optional) Specifies the Kind of CosmosDB to create - possible values are `GlobalDocumentDB`, `MongoDB` and `Parse`. Defaults to `GlobalDocumentDB`. Changing this forces a new resource to be created.

Expand Down