
Amazon DynamoDB is a fast, fully managed NoSQL database service offered by AWS.
You can use DynamoDB's incremental export feature to export data to Amazon S3, which is a cost-effective way to store and process large amounts of data.
The incremental export feature allows you to export only the new or updated data in your DynamoDB table, which can help reduce the amount of data being transferred and stored.
This feature is especially useful for applications that require data to be processed in real-time, such as analytics or machine learning workloads.
DynamoDB supports various data formats for export, including CSV, Parquet, and Avro.
For more insights, see: S3 as Data Lake
What is Incremental Export
Incremental export is a feature in Amazon DynamoDB that allows data engineers to continuously export changes in a DynamoDB table to an Amazon S3 bucket.
This feature is particularly beneficial for scenarios where near real-time data synchronization and analysis are required. By using this capability, engineers can effectively track modifications to items within a table and export only the changed data records to S3, minimizing the processing overhead and improving efficiency.
To enable incremental export, you can specify the ExportStatus parameter in the IncrementalExportSpecification, which can be set to "ENABLED" to start the export process.
The IncrementalExportSpecification also allows you to track the export status of a DynamoDB table, which can be useful for monitoring the export process.
Cost and Limitations
The cost of deploying an Amazon DynamoDB incremental export to Amazon S3 solution can be impacted by several factors, including the size of your DynamoDB table and how frequently you run the exports and the workflow.
The table below breaks down a potential cost breakdown structure with some assumptions:
Cost
The cost of deploying this solution is a crucial consideration.
Amazon DynamoDB PITR costs $0.20 per month for 1GB of storage.
AWS Step Functions are a significant expense, costing $5.38 per month for ~12 invocations per hour and 25 invocations per workflow.
AWS Lambda is essentially free, with a cost of $0.00 per month for ~12 invocations per hour and 128MB memory.
AWS KMS also incurs a cost, $1.01 per month for 1 CMK and ~3000 symmetric requests.
Here's a breakdown of the estimated monthly costs for this solution:
These costs can add up quickly, so it's essential to carefully consider the pricing for each service.
Incremental Exportで指定できる期間の最小幅は15分、最大幅は24時間、最大取得データサイズは100TB。最大同時実行数は300

This means that you can't set a time frame shorter than 15 minutes for an Incremental Export, which can impact data delivery times, especially when using CDC to save data to S3.
The maximum time frame you can set for an Incremental Export is 24 hours, giving you a decent amount of flexibility when it comes to scheduling exports.
The maximum data size you can export in a single Incremental Export is 100TB, which is a significant limitation to consider when working with large datasets.
With a maximum of 300 concurrent jobs allowed, you'll need to keep an eye on this limit when exporting large amounts of data over a long period of time.
Deployment and Validation
To deploy Amazon DynamoDB incremental export to Amazon S3, you should first ensure that the CDK deployed without any errors in the CLI.
Verify that the Step Function is fully deployed and runs without any errors. If you find any errors, refer to the Troubleshooting section for assistance.
Extract the export data bucket name, which is export named $DEPLOYMENT_ALIAS-data-export-output, from the output parameters of the CDK deployment.
Intriguing read: Aws Cdk S3 Bucket
Deployment Validation

Deployment validation is crucial to ensure a smooth deployment process. You should verify that the CDK deployed without any errors in the CLI.
A fully deployed Step Function is a good indicator of a successful deployment. The Step Function should run without any errors.
Extracting the export data bucket name from the output parameters of the CDK deployment is a must. The export data bucket name is named $DEPLOYMENT_ALIAS-data-export-output.
If you find any errors during the deployment, refer to the Troubleshooting section for guidance.
Related reading: S3 Bucket Naming
Redeployment
Redeployment can be a bit tricky, but it's a crucial step in ensuring your existing export data bucket and prefix are used.
If you're redeploying the solution, you'll need to pass the bucket name and prefix into the CDK synth and CDK deploy steps. This ensures your existing export data bucket and prefix are used.
You'll want to make sure to keep the export data bucket and prefix intact during redeployment.
3 Answers

There is an Athena connector that allows you to query your data in a DynamoDB table directly using a SQL query.
You can use a Lambda function to invoke a workflow using the Step Functions API, which can be scheduled to fire a few times a day based on a CRON expression.
The Lambda function can be triggered by a scheduled event created using an Amazon CloudWatch Event, which can be set up using a CRON expression.
Here are some ways to handle incremental export from Dynamo to any target:
- Use a CRON expression to schedule when the Lambda function is fired.
- Create a scheduled event that invokes an AWS Lambda function using an Amazon CloudWatch Event.
- Invoke a workflow from the Lambda function using the AWS Step Functions API.
Error Handling and Troubleshooting
If you've successfully run an incremental export workflow in the past, but then disabled and reenabled PITR, you'll likely encounter the "Incremental export start time outside PITR window" error.
This error occurs because there might be a gap in the time window when PITR was potentially not enabled, resulting in data loss.
To remediate this issue, set the /incremental-export/$DEPLOYMENT_ALIAS/workflow-action parameter to RESET_WITH_FULL_EXPORT_AGAIN, allowing the workflow to be reinitialized with a full export.
A full export is necessary to ensure no data loss occurs, and it will reinitialize the workflow.
This approach ensures that the incremental export workflow is properly reinitialized without any data loss issues.
State Information and Specifications
The solution maintains SSM Parameters to ensure incremental exports work as expected.
To manage the incremental export process, the solution tracks three key pieces of information: Full export and incremental exports, Workflow states, and Workflow actions. These details help the repeating logic decide what to do next.
Here's a breakdown of the key information maintained by the solution:
- Full export and incremental exports
- Workflow states
- Workflow actions
State Information
State Information is a crucial aspect of any system, and in this case, it's used to maintain SSM Parameters for incremental exports.
These parameters ensure that incremental exports work as expected, without requiring you to manually intervene.
The repeating logic in the system relies on these parameters to decide what to do next.
Here are the key components of State Information:
- Full export and incremental exports
- Workflow states
- Workflow actions
These components work together to provide a comprehensive view of the system's state, allowing for smoother and more efficient operations.
Incremental Export Specification for Data Engineering
Incremental Export Specification for Data Engineering is a powerful tool that allows data engineers to export changes in a DynamoDB table to an Amazon S3 bucket in near real-time. This feature is particularly beneficial for scenarios where data synchronization and analysis are required.

To configure the IncrementalExportSpecification, you can specify several parameters, including TableName, ExportStatus, KinesisStreamArn, ExportArn, StartTime, SegmentCount, and Segment. By using these parameters, engineers can effectively track modifications to items within a table and export only the changed data records to S3, minimizing processing overhead and improving efficiency.
The IncrementalExportSpecification can be configured using the AWS SDK, such as the boto3 SDK in Python. For example, you can use the following code snippet to update the export time for a specified ExportArn: response = ddb.update_export_time(ExportArn='arn:aws:dynamodb:us-west-2:1234567890:table/UserActivity/export/1234567890', ExportTime=timestamp). This code snippet triggers the incremental export process for the DynamoDB table, capturing only the changes made after the specified time.
The IncrementalExportSpecification has several limitations, including a minimum export period of 15 minutes and a maximum export period of 24 hours. Additionally, the maximum concurrent export jobs is 300, and the maximum table size is 100TB. These limitations should be taken into account when designing an incremental export process.
DynamoDB's Incremental Export feature can be used to create a CDC-like process, where data is exported to S3 in near real-time. However, it's worth noting that this feature has some constraints, and in some cases, it may not be possible to obtain an exact CDC. If strict CDC requirements are needed, it's recommended to use DynamoDB Streams or Kinesis Streams instead.
Worth a look: Access Denied Service Amazon S3 Status Code 403
Technical Details
To export data from Amazon DynamoDB to Amazon S3 incrementally, you'll need to use DynamoDB's export feature, which allows you to export data from a DynamoDB table to an S3 bucket.
DynamoDB supports two types of exports: full table exports and incremental exports. For incremental exports, you'll need to specify a DynamoDB stream, which captures changes to your table.
The export process involves creating an export task, which can take several hours to complete, depending on the size of your table and the speed of your network connection.
DynamoDB exports data in CSV format, which can be easily read by most data processing tools.
Frequently Asked Questions
Are transfers between S3 buckets or from Amazon S3 to any service within the same AWS region are free?
Yes, transfers between S3 buckets or from Amazon S3 to any service within the same AWS region are free of charge. However, storage management features incur additional costs.
Sources
- https://github.com/aws-samples/dynamodb-continuous-incremental-exports/blob/main/README.md
- https://github.com/aws-solutions-library-samples/guidance-for-incremental-data-exports-on-aws
- https://www.getorchestra.io/guides/aws_data_engineering_concepts_in_amazon_dynamodb_incrementalexportspecification_for_analytics_engineers
- https://tech.layerx.co.jp/entry/dynamodb-incremental-export
- https://stackoverflow.com/questions/68041291/incremental-exports-from-amazon-dynamodb-to-amazon-s3
Featured Images: pexels.com