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

azurerm_cosmosdb_account - support the Serverless value for the capabilities property #8533

Merged
merged 6 commits into from
Sep 21, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func resourceArmCosmosDbAccount() *schema.Resource {
"EnableCassandra",
"EnableGremlin",
"EnableTable",
"Serverless",
Copy link
Contributor

Choose a reason for hiding this comment

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

running the test for this we're getting:

Error: Error creating CosmosDB Account "acctest-ca-200921081838097854" (Resource Group "acctestRG-cosmos-200921081838097854"): Error creating/updating CosmosDB Account "acctest-ca-200921081838097854" (Resource Group "acctestRG-cosmos-200921081838097854"): documentdb.DatabaseAccountsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="Invalid capability Serverless.\r\nActivityId: 5dfe90e2-a83c-4a61-af17-3422cdd0de68, Microsoft.Azure.Documents.Common/2.11.0"

Provisioning one of these in the Azure Portal and then generating the ARM Template here gives us:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "string"
        },
        "location": {
            "type": "string"
        },
        "locationName": {
            "type": "string"
        },
        "defaultExperience": {
            "type": "string"
        },
        "isZoneRedundant": {
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "apiVersion": "2020-04-01",
            "kind": "GlobalDocumentDB",
            "type": "Microsoft.DocumentDb/databaseAccounts",
            "name": "[parameters('name')]",
            "location": "[parameters('location')]",
            "properties": {
                "databaseAccountOfferType": "Standard",
                "locations": [
                    {
                        "id": "[concat(parameters('name'), '-', parameters('location'))]",
                        "failoverPriority": 0,
                        "locationName": "[parameters('locationName')]"
                    }
                ],
                "backupPolicy": {
                    "type": "Periodic",
                    "periodicModeProperties": {
                        "backupIntervalInMinutes": 240,
                        "backupRetentionIntervalInHours": 8
                    }
                },
                "isVirtualNetworkFilterEnabled": false,
                "virtualNetworkRules": [],
                "ipRules": [],
                "dependsOn": [],
                "capabilities": [
                    {
                        "name": "EnableServerless"
                    }
                ],
                "enableFreeTier": false
            },
            "tags": {
                "defaultExperience": "[parameters('defaultExperience')]",
                "hidden-cosmos-mmspecial": "",
                "CosmosAccountType": "Non-Production"
            }
        }
    ],
    "outputs": {}
}

With the variables:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "value": "testtttttttttt"
        },
        "location": {
            "value": "westus"
        },
        "locationName": {
            "value": "West US"
        },
        "defaultExperience": {
            "value": "Core (SQL)"
        },
        "isZoneRedundant": {
            "value": "false"
        }
    }
}

Since we're using that API version, perhaps this also needs the tags set to be able to provision this?

It's worth noting in the preview documentation that Microsoft says at this time this is only available via the Azure Portal, so there could be some behind-the-scenes magic here too:

During the preview release, the only supported way to create a new serverless account is by using the Azure portal. Migrating existing accounts to/from serverless mode is not currently supported.

"EnableMongo",
"MongoDBv3.4",
"mongoEnableDocLevelTTL",
Expand Down