Sources
DynamoDB source setup
Replicate a DynamoDB table with Artie: stream changes from DynamoDB Streams and backfill existing rows from a point-in-time export in S3.
Required settings
Have these ready before you create the pipeline:
- The Stream ARN of the table’s DynamoDB stream. The stream’s view type must be
NEW_IMAGEorNEW_AND_OLD_IMAGES. - A service account: an IAM user’s access key, or an IAM role that Artie assumes.
- Point-in-time recovery (PITR) enabled on the table, if you want Artie to backfill it.
Each pipeline replicates one DynamoDB table. Artie reads the table name from the stream ARN.
Find the stream ARN
In the AWS console, open the table’s Exports and streams tab. DynamoDB stream details shows the View type and the Latest stream ARN.
Create a service account with Terraform
This Terraform creates one IAM policy, an IAM role that Artie assumes, and an IAM user with an access key. The policy lets Artie read the stream, start exports, and read exports in the artie-exports bucket. Replace artie-exports with your bucket name.
provider "aws" {
region = "us-east-1"
}
resource "aws_iam_role" "dynamodb_streams_role" {
name = "DynamoDBStreamsRole"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Principal = {
# Artie's AWS principal, which assumes this role
AWS = "arn:aws:iam::788826912768:user/ci"
},
Effect = "Allow",
# Optional. Remove this block if you leave AWS external ID blank in Artie.
Condition = {
StringEquals = {
"sts:ExternalId" = "my-external-id"
}
}
}
]
})
}
resource "aws_iam_policy" "dynamodb_streams_access" {
name = "DynamoDBStreamsAccess"
description = "Policy that grants access to DynamoDB streams and exports for Artie"
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"dynamodb:GetShardIterator",
"dynamodb:DescribeStream",
"dynamodb:GetRecords",
"dynamodb:ListStreams",
// We'll need this to check if the table has PITR enabled
"dynamodb:DescribeContinuousBackups",
// Required for export
"dynamodb:DescribeTable",
"dynamodb:ListExports",
"dynamodb:DescribeExport",
"dynamodb:ExportTableToPointInTime"
],
// Don't want to use "*"? You can specify like this:
// Resource = [ TABLE_ARN, TABLE_ARN + "/stream/*" ]
Resource = "*" # Modify this to restrict access to specific streams or resources
},
// Export (snapshot) requires access to S3
{
"Effect" : "Allow",
"Action" : [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource" : "arn:aws:s3:::artie-exports"
},
{
"Effect" : "Allow",
"Action" : [
"s3:GetObject",
// Required for export
"s3:PutObject"
],
"Resource" : "arn:aws:s3:::artie-exports/*"
}
]
})
}
resource "aws_iam_role_policy_attachment" "dynamodb_streams_role_policy_attachment" {
role = aws_iam_role.dynamodb_streams_role.name
policy_arn = aws_iam_policy.dynamodb_streams_access.arn
}
output "service_role_arn" {
value = aws_iam_role.dynamodb_streams_role.arn
}
resource "aws_iam_user" "dynamodb_streams_user" {
name = "dynamodb-artie-user"
path = "/"
}
resource "aws_iam_user_policy_attachment" "user_dynamodb_streams_attachment" {
user = aws_iam_user.dynamodb_streams_user.name
policy_arn = aws_iam_policy.dynamodb_streams_access.arn
}
resource "aws_iam_access_key" "dynamodb_streams_user_key" {
user = aws_iam_user.dynamodb_streams_user.name
}
output "aws_access_key_id" {
value = aws_iam_access_key.dynamodb_streams_user_key.id
sensitive = true
}
output "aws_secret_access_key" {
value = aws_iam_access_key.dynamodb_streams_user_key.secret
sensitive = true
}The outputs service_role_arn, aws_access_key_id and aws_secret_access_key are the values you enter in Artie.
Authentication method
In the Dashboard, choose an Authentication method. The Terraform script sets up both methods. You only need the resources for the method you pick.
| Method | Field | Value |
|---|---|---|
| Static credentials | AWS access key ID | The aws_access_key_id output |
| Static credentials | AWS secret access key | The aws_secret_access_key output |
| Role assumption | AWS role ARN | The service_role_arn output |
| Role assumption | AWS external ID (optional) | The sts:ExternalId value in the role’s trust policy |
Leave AWS external ID (optional) blank if the trust policy has no sts:ExternalId condition. Artie assumes the role as the AWS principal arn:aws:iam::788826912768:user/ci.
Connect DynamoDB in Artie
The pipeline setup has no Network access or Choose tables step for DynamoDB.
Choose DynamoDB
On the Dashboard home page, select New pipeline. On the Choose source step, select DynamoDB.
Prepare the service account
The Prepare source step shows the Terraform script. Run it if you haven’t created the service account, then select Continue.
Enter the connection details
On the Connect and verify step, enter the Stream ARN. Pick an Authentication method and fill in its fields.
Verify the source
Select Verify source. Artie shows “Source verified”. Select Continue.
If the stream has another view type, the error details include
stream view type is not NEW_IMAGE or NEW_AND_OLD_IMAGES.Set up the destination
Complete the Destination steps for your destination.
Choose the backfill settings
On the Backfill settings step, choose whether Artie backfills the table. See Backfills.
Deploy the pipeline
On the Review and deploy step, select Validate and deploy.
To edit the connection on an existing pipeline, open the Source: DynamoDB tab on the pipeline page.
Backfills
To backfill, Artie loads a point-in-time export of the table from S3. Artie starts the export, or uses one you started in the AWS console or CLI. Exports don’t use the table’s read capacity. AWS charges a full export by the size of the table, including its local secondary indexes, at the export time.
Export requirements
For Artie to start an export, the table needs PITR enabled. The service account needs these permissions:
| Resource | Permissions |
|---|---|
| DynamoDB table | dynamodb:ExportTableToPointInTime |
| S3 bucket | s3:AbortMultipartUpload, s3:PutObject, s3:PutObjectAcl |
The Terraform script grants dynamodb:ExportTableToPointInTime and s3:PutObject. It doesn’t grant s3:AbortMultipartUpload or s3:PutObjectAcl. Add both to the statement for arn:aws:s3:::artie-exports/* before you select Start an export.
An existing export must be less than 24 hours old and must not have failed. DynamoDB Streams keeps 24 hours of changes, so an older export leaves a gap in the destination table.
Set up the backfill
The setup shows the Backfill settings step after the destination steps.
- Set Would you like us to backfill? to Yes. The default is No.
- To start a new export, enter the S3 bucket name, then select Start an export.
- To use an existing export, select it under Export ARN.
- Select Validate to check the export. The button changes to Validated.
- Select Continue.
With No, Artie skips the backfill and streams new changes only.
Folder name (optional) sets a folder in the bucket for a new export. Backfill batch size (rows) offers 5k (the default), 10k, 25k and 50k.
Artie doesn’t deploy a pipeline whose backfill is on without an export. The Review and deploy step then shows Choose the export to backfill from.
To backfill a deployed pipeline, run an ad hoc backfill. Its dialog shows the same export fields.
Export errors
Under Export ARN, Artie disables exports that failed or are more than 24 hours old. Validation stops with one of these errors when the export can’t be used:
| Error | Fix |
|---|---|
this DynamoDB export is older than 24 hours so it cannot be used for backfilling | Start a new export with Start an export. |
this DynamoDB export failed so it cannot be used for backfilling | Read the AWS failure code and message in the error, fix the cause, then start a new export. |
this DynamoDB export is not in the specified S3 bucket | Enter the export’s bucket under S3 bucket name, or clear the field. |
Advanced
These sections cover exports to another AWS account and how Artie handles expired stream records.
Export to an S3 bucket in another AWS account
When the export bucket and the DynamoDB table are in different AWS accounts, the export request must name the bucket’s account. Artie sends that account ID when you start the export from the backfill settings.
You need two things:
- The 12-digit AWS account ID that owns the S3 bucket
- Permission to edit the bucket policy in that account
Set up the bucket, the role, then the export:
Grant Artie's role access in the bucket policy
The bucket policy must let the role (or IAM user) you gave Artie list the bucket, write the export, and read the exported files. This example lets the role
artie-dynamodbin account111122223333, where the table lives, use the bucketartie-exportsin account444455556666:JSON{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/artie-dynamodb" }, "Action": ["s3:ListBucket", "s3:GetBucketLocation"], "Resource": "arn:aws:s3:::artie-exports" }, { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/artie-dynamodb" }, "Action": [ "s3:GetObject", "s3:PutObject", "s3:PutObjectAcl", "s3:AbortMultipartUpload" ], "Resource": "arn:aws:s3:::artie-exports/*" } ] }Add the export actions to the role's IAM policy
Cross-account access needs both accounts to allow it. In the role’s IAM policy, add
s3:PutObjectAclands3:AbortMultipartUploadto the statement forarn:aws:s3:::artie-exports/*, next tos3:GetObjectands3:PutObject.Start the export with the bucket owner
On the Backfill settings step, enter the bucket name under S3 bucket name. Enter the owner’s account ID (
444455556666in this example) under Bucket owner account ID (optional). Then select Start an export.Leave Bucket owner account ID (optional) blank when the bucket is in the same account as the table.
This table lists what Artie shows when part of the cross-account setup is missing:
| What’s missing | What Artie shows | Fix |
|---|---|---|
| A 12-digit owner account ID | Artie does not start the export and shows Couldn’t start the export. The details say s3BucketOwner must be a 12-digit AWS account ID. | Enter the account ID only, not an ARN. |
s3:ListBucket in the bucket policy | Artie does not start the export. The details begin with failed to list S3 bucket. | Add the first statement from the example bucket policy. |
s3:GetObject in the bucket policy | The export finishes, but validation fails with service account cannot read DynamoDB export objects under s3://artie-exports/<folder>/. | Add s3:GetObject to the second statement of the bucket policy, then validate again. A new export is not needed. |
If you start the export yourself in the AWS console or CLI, pass the owner there. For example, add --s3-bucket-owner 444455556666 to aws dynamodb export-table-to-point-in-time. Then select the export under Export ARN in Artie. Artie reads the bucket and folder from the export, so you don’t enter the owner in that case.
Stream retention and expired shards
DynamoDB Streams keeps each change record for 24 hours. Artie reads the stream shard by shard, starting each new shard from its oldest record.
Artie skips a closed shard when it is more than 24 hours old and AWS deleted its records before Artie first read it. Artie then reads the shards after it.
This is expected right after you create a pipeline, when the backfill is newer than the expired shard. The backfill already includes those changes.
A shard Artie was already partway through isn’t skipped. If its records expire, the reader stops with an error so the gap doesn’t go unnoticed. Backfill the table to recover.
Was this page helpful?
- Need help? Message us on Slack or email [email protected].
- Want a walkthrough? Book a demo.
- LLM? Read llms.txt.