AWS::Cassandra::Table - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::Cassandra::Table

You can use the AWS::Cassandra::Table resource 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 Amazon CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Cassandra::Table", "Properties" : { "BillingMode" : BillingMode, "ClientSideTimestampsEnabled" : Boolean, "ClusteringKeyColumns" : [ ClusteringKeyColumn, ... ], "DefaultTimeToLive" : Integer, "EncryptionSpecification" : EncryptionSpecification, "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

ClientSideTimestampsEnabled

Enables client-side timestamps for the table. By default, the setting is disabled. You can enable client-side timestamps with the following option:

  • status: "enabled"

After client-side timestamps are enabled for a table, you can't disable this setting.

Required: No

Type: Boolean

Update requires: Replacement

ClusteringKeyColumns

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

Required: No

Type: Array of ClusteringKeyColumn

Update requires: Replacement

DefaultTimeToLive

The default Time To Live (TTL) value for all rows in a table in seconds. The maximum configurable value is 630,720,000 seconds, which is the equivalent of 20 years. By default, the TTL value for a table is 0, which means data does not expire.

For more information, see Setting the default TTL value for a table in the Amazon Keyspaces Developer Guide.

Required: No

Type: Integer

Minimum: 0

Update requires: No interruption

EncryptionSpecification

The encryption at rest options for the table.

  • Amazon owned key (default) - The key is owned by Amazon Keyspaces.

  • Customer managed key - The key is stored in your account and is created, owned, and managed by you.

    Note

    If you choose encryption with a customer managed key, you must specify a valid customer managed KMS key with permissions granted to Amazon Keyspaces.

For more information, see Encryption at rest in Amazon Keyspaces in the Amazon Keyspaces Developer Guide.

Required: No

Type: EncryptionSpecification

Update requires: No interruption

KeyspaceName

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

Required: Yes

Type: String

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

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: Array of Column

Minimum: 1

Update requires: Replacement

PointInTimeRecoveryEnabled

Specifies if point-in-time recovery is enabled or disabled for the table. The options are PointInTimeRecoveryEnabled=true and PointInTimeRecoveryEnabled=false. If not specified, the default is PointInTimeRecoveryEnabled=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.

You can add regular columns to existing tables by adding them to the template.

Required: No

Type: Array 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, Amazon 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 can't perform updates that require replacing this resource. You can perform updates that require no interruption 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

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

Update requires: Replacement

Tags

An array of key-value pairs to apply to this resource.

For more information, see Tag.

Required: No

Type: Array of Tag

Minimum: 0

Maximum: 50

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 has the name my_table, and uses on-demand billing.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "myNewTable": { "Type": "AWS::Cassandra::Table", "Properties": { "KeyspaceName": "my_keyspace", "TableName":"my_table", "PartitionKeyColumns": [ { "ColumnName": "Message", "ColumnType": "ASCII" } ] } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: myNewTable: Type: 'AWS::Cassandra::Table' Properties: KeyspaceName: my_keyspace TableName: my_table PartitionKeyColumns: - ColumnName: Message ColumnType: ASCII

Create a table with client-side timestamps and other options

The following example creates a table my_table with client-side timestamps and all other available options. For example, provisioned read and write capacity, default TTL, PITR, and tags.

JSON

{ "AWSTemplateFormatVersion":"2010-09-09", "Resources":{ "myNewTable":{ "Type":"AWS::Cassandra::Table", "Properties":{ "KeyspaceName":"my_keyspace", "TableName":"my_table", "PartitionKeyColumns":[ { "ColumnName":"id", "ColumnType":"ASCII" } ], "ClusteringKeyColumns":[ { "Column":{ "ColumnName":"division", "ColumnType":"ASCII" }, "OrderBy":"ASC" } ], "RegularColumns":[ { "ColumnName":"name", "ColumnType":"TEXT" }, { "ColumnName":"region", "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 } }, "ClientSideTimestampsEnabled":true, "DefaultTimeToLive":63072000, "PointInTimeRecoveryEnabled":true, "Tags":[ { "Key":"tag1", "Value":"val1" }, { "Key":"tag2", "Value":"val2" } ] } } } }

YAML

AWSTemplateFormatVersion: '2010-09-09' Resources: myNewTable: Type: AWS::Cassandra::Table Properties: KeyspaceName: my_keyspace TableName: my_table PartitionKeyColumns: - ColumnName: id ColumnType: ASCII ClusteringKeyColumns: - Column: ColumnName: division ColumnType: ASCII OrderBy: ASC RegularColumns: - ColumnName: name ColumnType: TEXT - ColumnName: region 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 ClientSideTimestampsEnabled: true DefaultTimeToLive: 63072000 PointInTimeRecoveryEnabled: true Tags: - Key: tag1 Value: val1 - Key: tag2 Value: val2

Create a table with customer managed keys and other options

The following example creates a table my_table with customer managed encryption keys and all other available options. For example, provisioned read and write capacity, default TTL, PITR, and tags. To use this sample, you must replace the key ARN in the example with your own.

JSON

{ "AWSTemplateFormatVersion":"2010-09-09", "Resources":{ "myNewTable":{ "Type":"AWS::Cassandra::Table", "Properties":{ "KeyspaceName":"my_keyspace", "TableName":"my_table", "PartitionKeyColumns":[ { "ColumnName":"id", "ColumnType":"ASCII" } ], "ClusteringKeyColumns":[ { "Column":{ "ColumnName":"division", "ColumnType":"ASCII" }, "OrderBy":"ASC" } ], "RegularColumns":[ { "ColumnName":"name", "ColumnType":"TEXT" }, { "ColumnName":"region", "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 } }, "DefaultTimeToLive":63072000, "EncryptionSpecification":{ "EncryptionType":"CUSTOMER_MANAGED_KMS_KEY", "KmsKeyIdentifier":"arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111" }, "PointInTimeRecoveryEnabled":true, "Tags":[ { "Key":"tag1", "Value":"val1" }, { "Key":"tag2", "Value":"val2" } ] } } } }

YAML

AWSTemplateFormatVersion: '2010-09-09' Resources: myNewTable: Type: AWS::Cassandra::Table Properties: KeyspaceName: my_keyspace TableName: my_table PartitionKeyColumns: - ColumnName: id ColumnType: ASCII ClusteringKeyColumns: - Column: ColumnName: division ColumnType: ASCII OrderBy: ASC RegularColumns: - ColumnName: name ColumnType: TEXT - ColumnName: region 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 DefaultTimeToLive: 63072000 EncryptionSpecification: EncryptionType: CUSTOMER_MANAGED_KMS_KEY KmsKeyIdentifier: arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111 PointInTimeRecoveryEnabled: true Tags: - Key: tag1 Value: val1 - Key: tag2 Value: val2

Add new columns to an existing table

The following example shows how to add five new columns to the existing table my_table. You can only add regular columns to a table.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "myTable": { "Type": "AWS::Cassandra::Table", "Properties": { "KeyspaceName": "my_keyspace", "TableName":"my_table", "PartitionKeyColumns": [ { "ColumnName": "Message", "ColumnType": "ASCII" } ], "RegularColumns": [ { "ColumnName": "name", "ColumnType": "TEXT" }, { "ColumnName": "region", "ColumnType": "TEXT" } ] } } } }

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "myTable": { "Type": "AWS::Cassandra::Table", "Properties": { "KeyspaceName": "my_keyspace", "TableName":"my_table", "PartitionKeyColumns": [ { "ColumnName": "Message", "ColumnType": "ASCII" } ], "RegularColumns": [ { "ColumnName": "name", "ColumnType": "TEXT" }, { "ColumnName": "region", "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" } ] } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: myTable: Type: 'AWS::Cassandra::Table' Properties: KeyspaceName: my_keyspace TableName: my_table PartitionKeyColumns: - ColumnName: Message ColumnType: ASCII RegularColumns: - ColumnName: name ColumnType: TEXT - ColumnName: region ColumnType: TEXT

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: myTable: Type: 'AWS::Cassandra::Table' Properties: KeyspaceName: my_keyspace TableName: my_table PartitionKeyColumns: - ColumnName: Message ColumnType: ASCII RegularColumns: - ColumnName: name ColumnType: TEXT - ColumnName: region 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