Terraform-provider-azurerm: Support for Free Tier on CosmosDB

Created on 8 Mar 2020  ·  11Comments  ·  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

CosmosDb now offers a free tier, where they give 400 RU/s and 5 GB of storage for free in an account. You can enable free tier on up to one account per subscription. Is it possible to support this? I am using Pulumi and raised the issue there https://github.com/pulumi/pulumi-azure/issues/480 and was told to raise it here.

I've added the Azure ARM template below as reference to the enableFreeTier property:

{
    "$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": "2019-12-12",
            "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')]"
                    }
                ],
                "enableMultipleWriteLocations": false,
                "isVirtualNetworkFilterEnabled": false,
                "virtualNetworkRules": [],
                "ipRangeFilter": "",
                "dependsOn": [],
                "capabilities": [],
                "enableFreeTier": true
            },
            "tags": {
                "defaultExperience": "[parameters('defaultExperience')]",
                "hidden-cosmos-mmspecial": "",
                "CosmosAccountType": "Non-Production"
            }
        }
    ],
    "outputs": {}
}

New or Affected Resource(s)

  • azurerm_cosmosdb
enhancement good first issue serviccosmosdb

Most helpful comment

@tombuildsstuff / @katbyte I am happy to submit a PR for this BUT it looks like the version of the cosmosdb SDK that the terraform provider is using will need updated to get access to this new property

Are you happy for me to upgrade this?

All 11 comments

any ETA on this ?

@tombuildsstuff / @katbyte I am happy to submit a PR for this BUT it looks like the version of the cosmosdb SDK that the terraform provider is using will need updated to get access to this new property

Are you happy for me to upgrade this?

Dependent on #6253

any ETA on this ?

Are there any workarounds, other than creating it manually using the Portal?

Azure CLI is also dependent on the SDK #13535

@evandropomatti I think it is possible to create this with an arm template. If you export a free tier in the portal the settings are there.

I had a quick look at the code to see what needs to change to get this parameter into the resource.

Looking at the Azure Golang SDK the free tier boolean is set here in the DatabaseAccountCreateUpdateProperties which is then passed on to a DatabaseAccountCreateUpdateParameters.
https://github.com/Azure/azure-sdk-for-go/blob/6095b427503b02f76316e8c6c2c5316854cbef52/services/cosmos-db/mgmt/2020-04-01/documentdb/models.go#L1334

The DatabaseAccountCreateUpdateParameters are set here in the provider, which contains a DatabaseAccountCreateUpdateProperties.
https://github.com/terraform-providers/terraform-provider-azurerm/blob/5e66b05b25c3d78a55d14ccbd544a58f089776b3/azurerm/internal/services/cosmos/cosmosdb_account_resource.go#L325

The problem is that the Azure provider uses an old version of the documentdb service, which does not include the specific property.
https://github.com/terraform-providers/terraform-provider-azurerm/blob/5e66b05b25c3d78a55d14ccbd544a58f089776b3/azurerm/internal/services/cosmos/cosmosdb_account_resource.go#L13

We would need to update the version to the latest 2020-04-01 to be able to the the property. The question is if this will have any implications for existing resources, or if there are any breaking changes that would occur. I can give it a try later when I have some time, but it would be nice if any of the maintainers has any input on this.

Depends on #7597

Can be closed now

This has been released in version 2.21.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.21.0"
}
# ... other configuration ...

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings