'Is there a way I can replicate a DynamoDb table but add a sort key to it?
I have some DynamoDb tables populated by data and which don't have a sort key configured. I read DDB doesn't let you add a sort key only at table creation and the only solution is to create a new table with the sort key configured.The problem is I need to keep the data I have stored but add a sort key to these tables. As a quick mention I'm deploying my backend using Serverless framework
I think one solution would be to use AWS's Data Pipeline service but I want to know if there are other options available. Thanks in advance.
EDIT:
My template for this resource looks like this:
resources:
Resources:
userGroupsTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: ${opt:stage, self:provider.stage, 'local'}-userGroups
AttributeDefinitions:
- AttributeName: 'userId'
AttributeType: 'S'
- AttributeName: 'organizationId'
AttributeType: 'S'
KeySchema:
- AttributeName: 'userId'
KeyType: 'HASH'
- AttributeName: 'organizationId'
KeyType: 'RANGE'
GlobalSecondaryIndexes:
- IndexName: 'organizationIdIndex'
KeySchema:
- AttributeName: 'organizationId'
KeyType: 'HASH'
Projection:
ProjectionType: 'ALL'
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StreamSpecification:
StreamViewType: "NEW_AND_OLD_IMAGES"
amazon-web-services">amazon-web-servicesamazon-dynamodb">amazon-dynamodbserverless-frameworkamazon-data-pipeline
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|