| page_title | astra_table Resource - terraform-provider-astra |
|---|---|
| subcategory | |
| description | astra_table provides a table resource which represents a table in cassandra. |
astra_table provides a table resource which represents a table in cassandra.
# Generate a random pet name to avoid naming conflicts
resource "random_pet" "pet_name" {}
# Create a new database
resource "astra_database" "example_db" {
# Required
name = substr("my-database-${random_pet.pet_name.id}", 0, 50)
keyspace = "example_keyspace"
cloud_provider = "gcp"
regions = ["us-central1"]
deletion_protection = false
}
# Create a new table
resource "astra_table" "example_table" {
# Required
keyspace = astra_database.example_db.keyspace
database_id = astra_database.example_db.id
region = astra_database.example_db.regions[0]
table = "a_table_of_data"
clustering_columns = "a:b"
partition_keys = "c:d"
column_definitions = [
{
Name : "a"
Static : false
TypeDefinition : "text"
},
{
Name : "b"
Static : false
TypeDefinition : "text"
},
{
Name : "c"
Static : false
TypeDefinition : "text"
},
{
Name : "d"
Static : false
TypeDefinition : "text"
},
{
Name : "e"
Static : false
TypeDefinition : "text"
},
{
Name : "f"
Static : false
TypeDefinition : "text"
}
]
}column_definitions(List of Map of String) A list of table Definitionsdatabase_id(String) Astra database to create the keyspace.keyspace(String) Keyspace name can have up to 48 alpha-numeric characters and contain underscores; only letters are supported as the first character.partition_keys(String) Partition key(s), separated by :region(String) region.table(String) Table name can have up to 48 alpha-numeric characters and contain underscores; only letters are supported as the first character.
clustering_columns(String) Clustering column(s), separated by :
id(String) The ID of this resource.
Import is supported using the following syntax:
# the import id includes the database_id, keyspace name, and table name.
terraform import astra_table.example 48bfc13b-c1a5-48db-b70f-b6ef9709872b/us-central1/keyspacename/tablename