Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional sort key as part of primary key #778

Merged
merged 5 commits into from
Sep 19, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion db/dynamodb-global-table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: >-
Create a global primary-key-lookup DynamoDB table
Create a global primary-key-lookup DynamoDB table with an optional sort key

Metadata:
AWS::CloudFormation::Interface:
Expand All @@ -13,6 +13,8 @@ Metadata:
- TableName
- PrimaryKey
- PrimaryType
- SortKey
- SortType
- ExpirationField
- Label:
default: Optional Regions
Expand Down Expand Up @@ -50,6 +52,10 @@ Metadata:
default: Primary key field
kookster marked this conversation as resolved.
Show resolved Hide resolved
PrimaryType:
default: Primary key type
kookster marked this conversation as resolved.
Show resolved Hide resolved
SortKey:
default: Sort key field
SortType:
default: Sort key type
ExpirationField:
default: Field to enable expiration on
Region2:
Expand Down Expand Up @@ -101,6 +107,16 @@ Parameters:
- String
- Numeric
- Binary
SortKey:
Type: String
Description: The name of the sort key field (optional)
SortType:
Type: String
Description: The type of the sort key field
AllowedValues:
- String
- Numeric
- Binary
ExpirationField:
Type: String
Description: Optionally enable Time-To-Live on this field
Expand Down Expand Up @@ -179,6 +195,7 @@ Conditions:
HasForeignAccount: !Not [!Equals [!Ref ForeignAccountId, ""]]
HasForeignRole: !Not [!Equals [!Ref ForeignRoleName, ""]]
HasProvisionedBilling: !Equals [!Ref BillingMode, "PROVISIONED"]
HasSortKey: !Not [!Equals [!Ref SortKey, ""]]

Mappings:
DataTypesMap:
Expand All @@ -196,10 +213,20 @@ Resources:
AttributeDefinitions:
- AttributeName: !Ref PrimaryKey
AttributeType: !FindInMap [DataTypesMap, !Ref PrimaryType, Symbol]
- Fn::If:
- HasSortKey
- AttributeName: !Ref SortKey
AttributeType: !FindInMap [DataTypesMap, !Ref SortType, Symbol]
- !Ref AWS::NoValue
BillingMode: !Ref BillingMode
KeySchema:
- AttributeName: !Ref PrimaryKey
KeyType: HASH
- Fn::If:
- HasSortKey
- AttributeName: !Ref SortKey
KeyType: RANGE
- !Ref AWS::NoValue
Replicas:
- ReadProvisionedThroughputSettings: !If
- HasProvisionedBilling
Expand Down
Loading