簡體   English   中英

Terraform 提供程序創建 cassandra 表

[英]Terraform provider to create cassandra tables

我希望在 Azure 上通過 terraform 創建 cassandra DB 表。 我已經有了相關的鍵空間。

我的部署是利用azurerm ,但是他們的配置器缺少 cassandra-tables 資源。 到目前為止,我只能通過門戶上的 Azure UI 或使用Azure CLI 腳本來部署 cassandra 表,但出於各種原因,這不是最佳解決方案。

有沒有提供者可以幫助我解決這個問題? 我正在環顧四周,但似乎我可以利用的東西不多。

無論出於何種原因,hashicorp 似乎從未在其提供程序中實現 cassandra 表。 他們的源代碼缺少它的實現。

我建議在他們的回購中提交一個新的錯誤。 你可以在這里

顯然,一種解決方法是使用ARM 提供程序以“增量”模式將資源部署到 Azure 作為 ARM。

 resource "azurerm_resource_group_template_deployment" "example" {
   depends_on = [module.cassandratest]

   name                = "example-cassandra-tables"
   resource_group_name = azurerm_resource_group.test.name
   deployment_mode     = "Incremental"
   template_content    = templatefile("resources/templatecosmos.json", {
     cosmos_db_account_name    = "test-cassandra-2",
     keyspace_name             = "keyspace1",
     table_name                = "test-table-2",
     autoscale_max_throughput  = 4000
   })
 }

CosmosDB Cassandra 模板在此處記錄。 resources/templatecosmos.json的內容示例:

{
 "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
 "contentVersion": "1.0.0.0",
 "parameters": {
    "accountName": {
       "type": "string",
       "defaultValue": "${cosmos_db_account_name}",
       "metadata": {
          "description": "Cosmos DB account name, max length 44 characters"
       }
    },
    "keyspaceName": {
       "type": "string",
       "defaultValue": "${keyspace_name}",
       "metadata": {
          "description": "The name for the Cassandra Keyspace"
       }
    },
    "tableName": {
       "type": "string",
       "defaultValue": "${table_name}",
       "metadata": {
          "description": "The name for the Cassandra table"
       }
    },
    "autoscaleMaxThroughput": {
       "type": "int",
       "defaultValue": "[int(${autoscale_max_throughput})]",
       "minValue": 4000,
       "maxValue": 1000000,
       "metadata": {
          "description": "Maximum autoscale throughput for the Cassandra table"
       }
    }
 },
 "variables": {
    "accountName": "[toLower(parameters('accountName'))]",
    "databaseRef": "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('accountName'))]",
    "keyspaceRef": "[resourceId('Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces', parameters('accountName'), parameters('keyspaceName'))]"
 },
  "resources": [
    {
       "type": "Microsoft.DocumentDb/databaseAccounts/cassandraKeyspaces/tables",
        "name": "[concat(variables('accountName'), '/', parameters('keyspaceName'), '/', parameters('tableName'))]",
        "apiVersion": "2020-04-01",
        "properties": {
           "resource": {
              "id": "[concat(parameters('tableName'))]",
              "schema": {
                 "columns": [
                    {
                       "name": "loadid",
                       "type": "uuid"
                    }
                 ],
                 "partitionKeys": [
                    { "name": "machine" },
                    { "name": "cpu" },
                    { "name": "mtime" }
                 ],
                 "clusterKeys": [
                    {
                       "name": "loadid",
                       "orderBy": "asc"
                    }
                 ]
              }
           },
           "options": {
              "autoscaleSettings": { 
                 "maxThroughput": "[parameters('autoscaleMaxThroughput')]" 
              }
           }
        }
     }
 ]
} 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM