Sources
DynamoDB source setup
Configure DynamoDB as a source in Artie using DynamoDB Streams, point-in-time recovery backfills, and S3 export for efficient data replication.
Required settings
- DynamoDB Streams ARN (view type must be set to
NEW_IMAGEorNEW_AND_OLD_IMAGES) - DynamoDB Table must have point-in-time recovery enabled if you want the table backfilled
- Service account
Finding DynamoDB Streams ARN
Creating a service account (Terraform)
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
}Authentication method
In the Dashboard, choose an Authentication method. The Terraform above sets up both. You only need the resources for the method you pick.
- Static credentials: enter the
aws_access_key_idandaws_secret_access_keyoutputs as AWS access key ID and AWS secret access key. - Role assumption: enter the
service_role_arnoutput as AWS role ARN. If the trust policy has ansts:ExternalIdcondition, enter the same value as AWS external ID.
Backfills
To backfill, Artie exports the table to S3 with point-in-time recovery and loads the export. Exports don’t use the table’s read capacity. AWS bills them per GB of table data exported.
An existing export you pick under Export ARN has to be less than 24 hours old and must not have failed. Otherwise validation stops with this DynamoDB export is older than 24 hours so it cannot be used for backfilling or this DynamoDB export failed so it cannot be used for backfilling. Start a new export with Start an export.
Advanced
Exporting to an S3 bucket in another AWS account
If your export bucket is in a different AWS account than your DynamoDB table, AWS only accepts the export when the request names the bucket’s account. Artie sends that account ID when you start the export from the backfill settings.
What you’ll need:
- The 12-digit AWS account ID that owns the S3 bucket
- Permission to edit the bucket policy in that account
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
In the pipeline’s backfill settings, enter the bucket name under S3 bucket name and the owner’s account ID (
444455556666in this example) under Bucket owner account ID (optional). Then click Start an export.Leave Bucket owner account ID (optional) blank when the bucket is in the same account as the table.
If something is missing:
- No bucket owner entered: AWS starts the export and then fails it with an access denied error. Validating the backfill settings shows
this DynamoDB export failed so it cannot be used for backfillingwith AWS’s failure code and message. Enter the owner’s account ID and start a new export. - Owner isn’t a 12-digit account ID: Artie doesn’t 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. - Bucket policy doesn’t grant
s3:ListBucket: Artie doesn’t start the export, and the details begin withfailed to list S3 bucket. Add the first statement from step 1. - Bucket policy doesn’t grant
s3:GetObject: the export finishes, but validation fails withservice account cannot read DynamoDB export objects under s3://artie-exports/<folder>/. Adds3:GetObjectto the second statement from step 1, then validate again. You don’t need a new export.
If you start the export yourself in the AWS console or CLI, pass the owner there, for example --s3-bucket-owner 444455556666 with 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.
If a closed shard is more than 24 hours old and AWS has already deleted its records when Artie first reads it, Artie skips that shard and moves on to 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.