AWS::Cassandra::Table - AWS CloudFormation

AWS::Cassandra::Table

The AWS::Cassandra::Table resource allows you to create a new table in Amazon Keyspaces (for Apache Cassandra). For more information, see Create a Keyspace and a Table in the Amazon Keyspaces Developer Guide.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Cassandra::Table", "Properties" : { "BillingMode" : BillingMode, "ClusteringKeyColumns" : [ ClusteringKeyColumn, ... ], "KeyspaceName" : String, "PartitionKeyColumns" : [ Column, ... ], "RegularColumns" : [ Column, ... ], "TableName" : String } }

Properties

BillingMode

The billing mode for the table, which determines how you'll be charged for reads and writes:

  • On-demand mode (default) - you pay based on the actual reads and writes your application performs.

  • Provisioned mode - lets you specify the number of reads and writes per second that you need for your application.

If you don't specify a value for this property, then the table will use on-demand mode.

Required: No

Type: BillingMode

Update requires: No interruption

ClusteringKeyColumns

One or more columns that determine how the table data is sorted.

Required: No

Type: List of ClusteringKeyColumn

Update requires: Replacement

KeyspaceName

The name of the keyspace in which to create the table. The keyspace must already exist.

Required: Yes

Type: String

Update requires: Replacement

PartitionKeyColumns

One or more columns that uniquely identify every row in the table. Every table must have a partition key.

Required: Yes

Type: List of Column

Update requires: Replacement

RegularColumns

One or more columns that are not part of the primary key - that is, columns that are not defined as partition key columns or clustering key columns.

Required: No

Type: List of Column

Update requires: No interruption

TableName

The name of the table to be created. If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the table name. For more information, see Name Type.

Important

If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

Length Constraints: Minimum length of 3. Maximum length of 255.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_]{1,47}$

Required: No

Type: String

Update requires: Replacement

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the name of the table and the keyspace where the table exists (delimited by '|'). For example:

{ "Ref": "myKeyspace|myTable" }

For more information about using the Ref function, see Ref.

Examples

Create a Table with Minimal Options

The following example creates a new table. The table will have a system-generated name, and will use on-demand billing.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MyNewTable": { "Type": "AWS::Cassandra::Table", "Properties": { "KeyspaceName": "MyNewKeyspace", "PartitionKeyColumns": [ { "ColumnName": "Message", "ColumnType": "ASCII" } ] } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: MyNewTable: Type: 'AWS::Cassandra::Table' Properties: KeyspaceName: MyNewKeyspace PartitionKeyColumns: - ColumnName: Message ColumnType: ASCII

Create a Table Using Provisioned Mode

The following example creates a table with specific read and write capacity.

JSON

{ "AWSTemplateFormatVersion":"2010-09-09", "Resources":{ "mySecondTable":{ "Type":"AWS::Cassandra::Table", "Properties":{ "KeyspaceName":"MyNewKeyspace", "TableName":"Employees", "PartitionKeyColumns":[ { "ColumnName":"id", "ColumnType":"ASCII" } ], "ClusteringKeyColumns":[ { "Column":{ "ColumnName":"division", "ColumnType":"ASCII" }, "OrderBy":"ASC" } ], "RegularColumns":[ { "ColumnName":"name", "ColumnType":"TEXT" }, { "ColumnName":"region", "ColumnType":"TEXT" }, { "ColumnName":"division", "ColumnType":"TEXT" }, { "ColumnName":"project", "ColumnType":"TEXT" }, { "ColumnName":"role", "ColumnType":"TEXT" }, { "ColumnName":"pay_scale", "ColumnType":"TEXT" }, { "ColumnName":"vacation_hrs", "ColumnType":"FLOAT" }, { "ColumnName":"manager_id", "ColumnType":"TEXT" } ], "BillingMode":{ "Mode":"PROVISIONED", "ProvisionedThroughput":{ "ReadCapacityUnits":5, "WriteCapacityUnits":5 } } } } } }

YAML

AWSTemplateFormatVersion: '2010-09-09' Resources: mySecondTable: Type: AWS::Cassandra::Table Properties: KeyspaceName: MyNewKeyspace TableName: Employees PartitionKeyColumns: - ColumnName: id ColumnType: ASCII ClusteringKeyColumns: - Column: ColumnName: division ColumnType: ASCII OrderBy: ASC RegularColumns: - ColumnName: name ColumnType: TEXT - ColumnName: region ColumnType: TEXT - ColumnName: division ColumnType: TEXT - ColumnName: project ColumnType: TEXT - ColumnName: role ColumnType: TEXT - ColumnName: pay_scale ColumnType: TEXT - ColumnName: vacation_hrs ColumnType: FLOAT - ColumnName: manager_id ColumnType: TEXT BillingMode: Mode: PROVISIONED ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5