AWS::Cassandra::Keyspace - AWS CloudFormation (original) (raw)
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 in the Amazon Keyspaces Developer Guide.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
Properties
ClientSideTimestampsEnabled
Indicates whether client-side timestamps are enabled (true) or disabled (false) for all tables in the keyspace. To add a Region to a single-Region keyspace with at least one table, the value must be set to true. After you've enabled client-side timestamps for a table, you can’t disable it again.
Required: No
Type: Boolean
Update requires: No interruption
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 1. Maximum length of 48.
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) orMULTI_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: No interruption
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
- Create a new multi-Region keyspace
- Add a new AWS Region to a single-Region keyspace
- Add a new AWS Region to a multi-Region keyspace
Create a new keyspace with tags
The following example creates a new keyspace namedMyNewKeyspace
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 namedMultiRegionKeyspace
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
Add a new AWS Region to a single-Region keyspace
The following example shows how to add the Region eu-west-1
to a single-Region keyspace namedMyNewKeyspace
that is currently available in us-east-1
.
JSON
{
"AWSTemplateFormatVersion":"2010-09-09",
"Resources":{
"MultiRegionKeyspace":{
"Type":"AWS::Cassandra::Keyspace",
"Properties":{
"KeyspaceName":"MyNewKeyspace",
"ReplicationSpecification":{
"ReplicationStrategy":"MULTI_REGION",
"RegionList":[
"us-east-1",
"eu-west-1"
]
},
"ClientSideTimestampsEnabled":true
}
}
}
}
YAML
AWSTemplateFormatVersion: 2010-09-09
Resources:
MultiRegionKeyspace:
Type: AWS::Cassandra::Keyspace
Properties:
KeyspaceName: MyNewKeyspace
ReplicationSpecification:
ReplicationStrategy: MULTI_REGION
RegionList:
- us-east-1
- eu-west-1
ClientSideTimestampsEnabled: true
Add a new AWS Region to a multi-Region keyspace
The following example shows how to add the new Region us-west-2
to the existing multi-Region keyspace namedMultiRegionKeyspace
that is already replicated across us-east-1
and eu-west-1
.
JSON
{
"AWSTemplateFormatVersion":"2010-09-09",
"Resources":{
"MultiRegionKeyspace":{
"Type":"AWS::Cassandra::Keyspace",
"Properties":{
"KeyspaceName":"MultiRegionKeyspace",
"ReplicationSpecification":{
"ReplicationStrategy":"MULTI_REGION",
"RegionList":[
"us-east-1",
"eu-west-1",
"us-west-2"
]
}
}
}
}
}
YAML
AWSTemplateFormatVersion: 2010-09-09
Resources:
MultiRegionKeyspace:
Type: AWS::Cassandra::Keyspace
Properties:
KeyspaceName: MultiRegionKeyspace
ReplicationSpecification:
ReplicationStrategy: MULTI_REGION
RegionList:
- us-east-1
- us-west-1
- us-west-2