Reputation: 243
I'm looking to create cassandra DB tables through terraform, on Azure. I already have the relative keyspaces in place.
My deployment is leveraging azurerm, however their provisioner is lacking a cassandra-tables resources. As of now, I can only deploy cassandra tables through Azure UI on the portal or with Azure CLI scripting, however this isn't the best solution for a variety of reasons.
Is there a provider that could help me with this? I'm giving a look around but it seems that there isn't much I could leverage.
Upvotes: 1
Views: 720
Reputation: 243
Apparently a workaround could be deploying the resource to Azure as ARM using the ARM provider in an "incremental" mode.
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 templates are documented here. An example of the contents of 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')]"
}
}
}
}
]
}
Upvotes: 2
Reputation: 8763
For whatever reason it looks like hashicorp never implemented cassandra table in their provider. Their source code is missing the implementation for it.
I suggest filing a new bug on their repo. You can do that here
Upvotes: 2