AWS::Cassandra::Keyspace - AWS CloudFormation

AWS::Cassandra::Keyspace

You can use the AWS::Cassandra::Keyspace resource to create a new keyspace 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::Keyspace", "Properties" : { "KeyspaceName" : String, "ReplicationSpecification" : ReplicationSpecification, "Tags" : [ Tag, ... ] } }

YAML

Type: AWS::Cassandra::Keyspace Properties: KeyspaceName: String ReplicationSpecification: ReplicationSpecification Tags: - Tag

Properties

KeyspaceName

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

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

ReplicationSpecification

Specifies the ReplicationStrategy of a keyspace. The options are:

  • SINGLE_REGION for a single Region keyspace (optional) or

  • MULTI_REGION for a multi-Region keyspace

If no ReplicationStrategy is provided, the default is SINGLE_REGION. If you choose MULTI_REGION, you must also provide a RegionList with the AWS Regions that the keyspace is replicated in.

Required: No

Type: ReplicationSpecification

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 keyspace. For example:

{ "Ref": "MyNewKeyspace" }

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

Examples

This section includes code examples that demonstrate how to create a keyspace using the different options.

Create a new keyspace with tags

The following example creates a new keyspace named MyNewKeyspace with the following tags: {'key1':'val1', 'key2':'val2'}.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MyNewKeyspace": { "Type": "AWS::Cassandra::Keyspace", "Properties": { "KeyspaceName": "MyNewKeyspace", "Tags": [{"Key":"tag1","Value":"val1"}, {"Key":"tag2","Value":"val2"}] } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: MyNewKeyspace: Type: AWS::Cassandra::Keyspace Properties: KeyspaceName: MyNewKeyspace Tags: - Key: tag1 Value: val1 - Key: tag2 Value: val2

Create a new multi-Region keyspace

The following example creates a new multi-Region keyspace named MultiRegionKeyspace that is replicated across three AWS Regions.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MultiRegionKeyspace": { "Type": "AWS::Cassandra::Keyspace", "Properties": { "KeyspaceName": "MultiRegionKeyspace", "ReplicationSpecification": { "ReplicationStrategy": "MULTI_REGION", "RegionList": ["us-east-1", "us-west-2", "eu-west-1"] } } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: MultiRegionKeyspace: Type: AWS::Cassandra::Keyspace Properties: KeyspaceName: MultiRegionKeyspace ReplicationSpecification: ReplicationStrategy: MULTI_REGION RegionList: - us-east-1 - us-west-2 - eu-west-1