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, ... ], "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

ClusteringKeyColumns

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

Required: No

Type: List 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

Update requires: No interruption

EncryptionSpecification

The encryption at rest options for the table.

  • AWS 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 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 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: 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": "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 using all options

The following example creates a table my_table with all available properties. For example, provisioned read and write capacity, default TTL, encryption settings, 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":"<emphasis>arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111</emphasis>" } }, "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. Only regular columns can be added 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