This repository accompanies the Cross Account Amazon DynamoDB Replication blog post. It contains two AWS Serverless Application Model (AWS SAM) templates.
- First template deploys an AWS Glue job used for loading the data from the source DynamoDB table to the target DynamoDB table. If you are using the native DynamoDB export feature, do not use this template. Only use this template if the source DynamoDB table size is less than 140GB and you are using AWS Glue job for export and import.
- The second template deploys one AWS Lambda function that reads from source DynamoDB stream and replicates the changes to the target Amazon DyanmoDB table in a different AWS account.
├── README.MD <-- This instructions file
├── InitialLoad <-- The SAM template for Initial Load using Glue for import and export
├── ChangeDataCapture <-- The SAM template for Change Data Capture (CDC)
├── InitialMigrationWithNativeExport <-- Sample Glue code to help you get started. Bash script to change the owner of the objects in the target S3 bucket.
- AWS CLI already configured with Administrator permission
- Install SAM CLI if you do not have it.
- Source and target tables created in DynamoDB
- Target IAM role created with permissions to write to target DynamoDB table
- For Change Data Capture, DynamoDB streams should be enabled on source table
Clone the repo onto your local development machine using git clone <repo url>
.
- From the command line, change directory to SAM template directory for Initial Load
cd InitialLoad
- Run the below commands to deploy the template
sam build
sam deploy --guided
Follow the prompts in the deploy process to set the stack name, AWS Region and other parameters.
- TargetDynamoDBTable: Target DynamoDB Table name
- TargetAccountNumber: Target AWS Account Number
- TargetRoleName: Target IAM Role name to be assumed by the Glue job
- TargetRegion: The region for the target DynamoDB table
- SourceDynamoDBTable: Source DynamoDB Table name
- WorkerType: The type of predefined worker that is allocated when a job runs. Accepts a value of Standard, G.1X, or G.2X.
- NumberOfWorkers: The number of workers of a defined workerType that are allocated when a job runs.
- JobName: Name of the Glue Job
- From the command line, change directory to SAM template directory for Initial Load
cd ChangeDataCapture
- Run the below commands to deploy the template
sam build
sam deploy --guided
Follow the prompts in the deploy process to set the stack name, AWS Region and other parameters.
- TargetDynamoDBTable: Target DynamoDB Table name
- TargetAccountNumber: Target AWS Account Number
- TargetRoleName: Target IAM Role name to be assumed by Lambda function
- TargetRegion: The region for the target DynamoDB table
- MaximumRecordAgeInSeconds: The maximum age (in seconds) of a record in the stream that Lambda sends to your function.
- SourceTableStreamARN: Source DynamoDB table stream ARN
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.