Skip to content

Configuration

Before running the command:

  • Enable DynamoDB Streams on the source table with NEW_IMAGE or NEW_AND_OLD_IMAGES.
  • Create the target table with the same partition key and optional sort key names and data types as the source table.

This requirement applies only to key attributes. DynamoDB non-key attributes are not declared when the table is created, and ddb-migrate preserves their data types and values.

Configuration file

ddb-migrate.toml:

toml
# ddb-migrate 先全量扫描 AWS DynamoDB 源表,再持续读取 DynamoDB Streams。

[source]
access_key_id = ""                        # AK/SK 都为空时使用 AWS 默认凭证链
secret_access_key = ""
region = "us-east-1"                     # 必填,不读取 AWS_REGION
table = "source_table"
checkpoint_enabled = true                 # 启用断点续传
checkpoint_file_path = "checkpoint.json"
scan_segments = 4                         # 全量 Scan 并行分段数

[target]
access_key_id = "username:password"        # Tair 使用“账号:密码”格式
secret_access_key = "dummy"               # 固定占位值
region = "us-east-1"                     # 自定义 endpoint 可省略,默认 us-east-1
endpoint_url = "http://your-endpoint:80"  # 自定义 endpoint 默认跳过 TLS 验证
table = "target_table"
workers = 4                                # 目标端并发写入 worker 数

The example lists every field. An empty string and an omitted string field have the same effect; omit Boolean and integer fields directly. The tables below describe the result. The [source] and [target] credentials are independent.

source

The migration source always uses official AWS DynamoDB and DynamoDB Streams endpoints and has no endpoint_url field.

OptionPurposeOmission rules and result
access_key_id, secret_access_keySource AWS credentialsOmit both or leave both empty to use the AWS default credential chain. Set both to use static AK/SK. Setting only one fails at startup.
regionAWS Region containing the source tableRequired. It must be set in TOML even when AWS_REGION exists in the runtime environment.
tableSource table nameRequired.
checkpoint_enabledPersist full-scan and incremental progressOptional; the default is false. When disabled, an interrupted run cannot resume and the next run performs the full Scan again.
checkpoint_file_pathCheckpoint file pathOptional; the default is checkpoint.json. The file is unused when checkpoint_enabled = false.
scan_segmentsNumber of parallel full-Scan segmentsOptional; the default is 4, and values less than or equal to 0 also use 4. Changing it prevents an incomplete old Scan checkpoint from being resumed, so the source table is scanned again.

target

OptionPurposeOmission rules and result
access_key_id, secret_access_keyTarget credentialsOmit both for an AWS target using the default credential chain. For Tair, set both: use account:password for access_key_id and the fixed value dummy for secret_access_key. Setting only one fails at startup.
regionRegion of an official AWS endpoint, or signing Region for a custom endpointRequired when endpoint_url is empty. Optional when endpoint_url is non-empty; the default is us-east-1. It can be omitted for Tair.
endpoint_urlTarget DynamoDB API addressOptional for an official AWS DynamoDB target, where region selects the endpoint. Required for Tair.
tableTarget table nameRequired.
workersNumber of concurrent target write workersOptional; the default is 4, and values less than or equal to 0 also use 4.

For a Tair target, the minimum required fields are access_key_id, secret_access_key, endpoint_url, and table. Both region and workers can be omitted.

AWS credential sources

When AK and SK are both non-empty in TOML, the program uses only those static credentials. When both fields are omitted or empty, the program uses the AWS SDK for Go v2 default credential chain.

RuntimeAK/SK in TOMLRuntime configuration
Environment variablesOmit both or leave both emptySet AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY; also set AWS_SESSION_TOKEN for temporary credentials.
Web IdentityOmit both or leave both emptyLet the runtime provide Web Identity settings, such as an IAM role for an EKS Pod.
AWS profile or IAM Identity CenterOmit both or leave both emptyUse ~/.aws/credentials and ~/.aws/config; select a named profile with AWS_PROFILE and complete the login required by that profile.
ECS task roleOmit both or leave both emptyAssign an IAM role to the ECS task.
EC2 instance roleOmit both or leave both emptyAssign an IAM role to the EC2 instance; the SDK obtains temporary credentials from the instance metadata service.

The default chain checks environment variables, Web Identity, shared credentials/config files, an ECS task role, and an EC2 instance role in order, and uses the first credentials it obtains. AK/SK environment variables therefore override an EC2 instance role. They also override a profile selected with AWS_PROFILE.

For example, on an EC2 instance with an IAM role, remove access_key_id and secret_access_key from [source] and keep region and table. If the target is Tair, its Tair account and password and the dummy value are still required in [target].

Example using a named profile:

shell
AWS_PROFILE=production ./ddb-migrate ddb-migrate.toml

If the default chain finds no credentials, the first AWS API request fails. See Configure the SDK - AWS SDK for Go v2 for the complete loading order.

Start

shell
./ddb-migrate ddb-migrate.toml

Released under the MIT License.