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, ... ]
, "PointInTimeRecoveryEnabled" :Boolean
, "RegularColumns" :[ Column, ... ]
, "TableName" :String
, "Tags" :[ Tag, ... ]
} }
YAML
Type: AWS::Cassandra::Table Properties: BillingMode:
BillingMode
ClusteringKeyColumns:- ClusteringKeyColumn
KeyspaceName:String
PartitionKeyColumns:- Column
PointInTimeRecoveryEnabled:Boolean
RegularColumns:- Column
TableName:String
Tags:- Tag
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
PointInTimeRecoveryEnabled
-
Specifies if point-in-time recovery is enabled or disabled for the table. The options are
PointInTimeRecoveryEnabled=true
andPointInTimeRecoveryEnabled=false
. If not specified, the default isPointInTimeRecoveryEnabled=false
.Required: No
Type: Boolean
Update requires: No interruption
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. The table name is case sensitive. 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
Tags
-
A list of key-value pair tags to be attached to the resource.
Required: No
Type: List of Tag
Update requires: No interruption
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
Create a Table with Point-in-time Recovery enabled and with tags.
The following example creates a table with point-in-time enabled and with tags.
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" } ], "PointInTimeRecoveryEnabled": true, "Tags": [ { "Key": "tag1", "Value": "val1" }, { "Key": "tag2", "Value": "val2" } ] } } } }
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 PointInTimeRecoveryEnabled: true Tags: - Key: tag1 Value: val1 - Key: tag2 Value: val2