AWS::Cassandra::Type - AWS CloudFormation (original) (raw)
The CreateType
operation creates a new user-defined type in the specified keyspace.
To configure the required permissions, see Permissions to create a UDT in the Amazon Keyspaces Developer Guide.
For more information, see User-defined types (UDTs) in the Amazon Keyspaces Developer Guide.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{
"Type" : "AWS::Cassandra::Type",
"Properties" : {
"Fields" : [ Field, ... ],
"KeyspaceName" : String,
"TypeName" : String
}
}
YAML
Type: AWS::Cassandra::Type
Properties:
Fields:
- Field
KeyspaceName: String
TypeName: String
Properties
Fields
A list of fields that define this type.
Required: Yes
Type: Array of Field
Update requires: Replacement
KeyspaceName
The name of the keyspace to create the type in. The keyspace must already exist.
Required: Yes
Type: String
Update requires: Replacement
TypeName
The name of the user-defined type. UDT names must contain 48 characters or less, must begin with an alphabetic character, and can only contain alpha-numeric characters and underscores. Amazon Keyspaces converts upper case characters automatically into lower case characters. For more information, see Create a user-defined type (UDT) in Amazon Keyspaces in the Amazon Keyspaces Developer Guide.
Required: Yes
Type: String
Update requires: Replacement
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the name of the type and the keyspace where the type exists (delimited by '|'). For example:
{ "Ref": "myKeyspace|myType" }
For more information about using the Ref
function, see Ref.
Fn::GetAtt
The Fn::GetAtt
intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt
intrinsic function, see Fn::GetAtt.
DirectParentTypes
A list of user-defined types that use this type.
DirectReferringTables
A list of tables that use this type.
KeyspaceArn
The unique identifier of the keyspace that contains this type in the format of Amazon Resource Name (ARN)
LastModifiedTimestamp
The last time this type was modified.
MaxNestingDepth
The maximum nesting depth of this type. For more information, see Amazon Keyspaces UDT quotas and default values in the Amazon Keyspaces Developer Guide.
Examples
This section includes code examples that demonstrate how to create and use user-defined types (UDTs).
Create a new UDT
The following example creates a new type namedmy_udt
.
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyNewKeyspaceResource": {
"Type": "AWS::Cassandra::Keyspace",
"Properties": {
"KeyspaceName": "my_keyspace"
}
},
"MyNewTypeResource": {
"Type": "AWS::Cassandra::Type",
"Properties": {
"KeyspaceName": "my_keyspace",
"TypeName": "my_udt",
"Fields": [
{
"FieldName": "field_1",
"FieldType": "int"
}
]
},
"DependsOn": "MyNewKeyspaceResource"
}
}
}
YAML
AWSTemplateFormatVersion: 2010-09-09
Resources:
MyNewKeyspaceResource:
Type: 'AWS::Cassandra::Keyspace'
Properties:
KeyspaceName: my_keyspace
MyNewTypeResource:
Type: 'AWS::Cassandra::Type'
Properties:
KeyspaceName: my_keyspace
TypeName: my_udt
Fields:
- FieldName: field_1
FieldType: int
DependsOn: "MyNewKeyspaceResource"
Create a new UDT with a nested UDT
The following example creates a new UDT namedparent_udt
that uses the nested type child_udt
.
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyNewKeyspaceResource": {
"Type": "AWS::Cassandra::Keyspace",
"Properties": {
"KeyspaceName": "my_ks"
}
},
"MyNewChildTypeResource": {
"Type": "AWS::Cassandra::Type",
"Properties": {
"KeyspaceName": "my_ks",
"TypeName": "child_udt",
"Fields": [
{
"FieldName": "field_a",
"FieldType": "int"
}
]
},
"DependsOn": "MyNewKeyspaceResource"
},
"MyNewParentTypeResource": {
"Type": "AWS::Cassandra::Type",
"Properties": {
"KeyspaceName": "my_ks",
"TypeName": "parent_udt",
"Fields": [
{
"FieldName": "child_type_field",
"FieldType": "frozen<child_udt>"
},
{
"FieldName": "int_field",
"FieldType": "int"
}
]
},
"DependsOn": ["MyNewChildTypeResource", "MyNewKeyspaceResource"]
}
}
}
YAML
AWSTemplateFormatVersion: 2010-09-09
Resources:
MyNewKeyspaceResource:
Type: 'AWS::Cassandra::Keyspace'
Properties:
KeyspaceName: my_ks
MyNewChildTypeResource:
Type: 'AWS::Cassandra::Type'
Properties:
KeyspaceName: my_ks
TypeName: child_udt
Fields:
- FieldName: field_a
FieldType: int
DependsOn: "MyNewKeyspaceResource"
MyNewParentTypeResource:
Type: 'AWS::Cassandra::Type'
Properties:
KeyspaceName: my_ks
TypeName: parent_udt
Fields:
- FieldName: child_type_field
FieldType: frozen<child_udt>
- FieldName: int_field
FieldType: int
DependsOn: ["MyNewChildTypeResource", "MyNewKeyspaceResource"]
Create a new table that uses UDTs
The following example creates a new table called my_table
that uses a UDT namedmy_udt
.
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyNewKeyspaceResource": {
"Type": "AWS::Cassandra::Keyspace",
"Properties": {
"KeyspaceName": "my_ks"
}
},
"MyNewTypeResource": {
"Type": "AWS::Cassandra::Type",
"Properties": {
"KeyspaceName": "my_ks",
"TypeName": "my_udt",
"Fields": [
{
"FieldName": "field_1",
"FieldType": "int"
}
]
},
"DependsOn": "MyNewKeyspaceResource"
},
"MyNewTableResource": {
"Type": "AWS::Cassandra::Table",
"Properties": {
"KeyspaceName": "my_ks",
"TableName": "my_table",
"PartitionKeyColumns": [
{
"ColumnName": "frozen_udt",
"ColumnType": "frozen<my_udt>"
}
],
"RegularColumns": [
{
"ColumnName": "udt_field",
"ColumnType": "my_udt"
},
{
"ColumnName": "other_field",
"ColumnType": "int"
}
]
},
"DependsOn": ["MyNewTypeResource", "MyNewKeyspaceResource"]
}
}
}
YAML
AWSTemplateFormatVersion: 2010-09-09
Resources:
MyNewKeyspaceResource:
Type: 'AWS::Cassandra::Keyspace'
Properties:
KeyspaceName: my_ks
MyNewTypeResource:
Type: 'AWS::Cassandra::Type'
Properties:
KeyspaceName: my_ks
TypeName: my_udt
Fields:
- FieldName: field_1
FieldType: int
DependsOn: "MyNewKeyspaceResource"
MyNewTableResource:
Type: 'AWS::Cassandra::Table'
Properties:
KeyspaceName: my_ks
TableName: my_table
PartitionKeyColumns:
- ColumnName: frozen_udt
ColumnType: frozen<my_udt>
RegularColumns:
- ColumnName: udt_field
ColumnType: my_udt
- ColumnName: other_field
ColumnType: int
DependsOn: ["MyNewTypeResource", "MyNewKeyspaceResource"]