Import and export

Import and export operations move many items. If one stops, Dynomate does not undo the completed work.

Import items [[dynamodb.import]]

Writes items into a table from inline data, a local file, an S3 object or another DynamoDB table. It checks the full source first. Sometimes destructive

[[dynamodb.import]]
name = "Load seed orders"
tableArn = "arn:aws:dynamodb:ap-southeast-2:123456789012:table/Orders-dev"
conflictMode = "skip-existing"
source = { type = "file", path = "seed/orders.jsonl" }
source.typeKeysNotes
"inline" items (required) Items in the request.
"file" path (required), format A local json, jsonl or csv file, with an optional .gz suffix. The default format comes from the file extension.
"s3" objectArn, or bucket and key. region (required). profileName, endpointUrl, format. An S3 object. profileName defaults to the operation profile.
"dynamodb-table" tableArn, region, profileName, endpointUrl, filterExpression, expressionAttributeNames, expressionAttributeValues, segments A scan of another table. It cannot be the destination.
# Items written in the request
source = { type = "inline", items = [{ accountId = "account#1", orderId = "order#1001" }] }

# An object in S3
source = { type = "s3", bucket = "commerce-seed-data", key = "orders/seed.csv", region = "ap-southeast-2", format = "csv" }

# Another DynamoDB table, optionally in another account
source = { type = "dynamodb-table", tableArn = "arn:aws:dynamodb:ap-southeast-2:111122223333:table/Orders", profileName = "commerce-prod" }
  • A JSON file has an array of items. Items can be plain or typed.
  • Dynomate imports CSV cells as strings, leaves out empty cells, and adds the warning csv-values-imported-as-strings.
  • Before it writes, Dynomate checks that each item parses, has the destination keys with the correct types, and has a unique key.
  • If a check fails, the operation fails with DNML_IMPORT_PREFLIGHT and writes nothing.
  • The import is destructive if conflictMode is "overwrite".
  • The result has importedCount, skippedCount, failedCount, totalItems and warnings.

Keys

source map Required
Where the items come from: "inline" items, a local "file", an "s3" object or another "dynamodb-table". Files can be JSON, JSON Lines or CSV, and Dynomate imports CSV values as strings. In the app: Source tab › Import source
conflictMode enum: "overwrite" | "skip-existing"
What Dynomate does when an item with the same key exists: "overwrite", the default, replaces it, and "skip-existing" keeps it. In the app: Source tab › Existing items
chunkSize integer
Items in each write call, from 1 to 25. The default is 25. In the app: Execution tab › Items per write
concurrency integer
The number of parallel write calls. The default is 8. In the app: Execution tab › Write concurrency
continueOnItemError boolean
If true, Dynomate counts failed items, and the import succeeds if it writes at least one item. The default is false. In the app: Execution tab › Continue after item errors

Export items [[dynamodb.export]]

Scans a table and writes its items to a local file in JSON, JSON Lines, CSV or DynamoDB JSON Lines format.

[[dynamodb.export]]
name = "Export orders"
tableArn = "arn:aws:dynamodb:ap-southeast-2:123456789012:table/Orders"
snapshot = true
target = { type = "file", path = "exports/", format = "dynamodb-jsonl" }
  • path can be:
    • A file. If the file exists, the export fails and does not overwrite it.
    • A directory. Dynomate makes a file name from the table name.
    • Not set. Dynomate writes to the exports folder in the app data directory.
  • dynamodb-jsonl keeps all DynamoDB types. Other formats write plain values: a set becomes a list, and binary becomes base64 text.
  • CSV has one column for each top-level attribute name, in sorted order. Nested values become JSON text.
  • An S3 target, type = "s3", is not supported and fails with DNML_UNSUPPORTED_OPERATION.
  • The app and the CLI share snapshots if they use the same app data directory. See Local SQL.
  • If the snapshot registration fails, the operation fails, but its result still has outputPath.
  • The result has outputPath, format, exportedCount, outputSizeBytes, segmentCount and, with snapshot = true, snapshotId.

A later import can read the export file:

source = { type = "file", path = "${export_orders.outputPath}", format = "jsonl" }

For a full example, see import-export.

Keys

target map Required
Where Dynomate writes the items: type "file", a path to a file or directory, and a format. The format is "jsonl-gzip", the default, or "jsonl", "json", "csv" or "dynamodb-jsonl". In the app: Output tab › Export target
segments integer
The number of parallel scan segments. By default, Dynomate sets it. In the app: Execution tab › Scan segments
scanLimit integer
Items in each scan page. The default is 1,000. In the app: Execution tab › Scan page size
filterExpression string
If set, Dynomate exports only the items that match. In the app: Scope tab › Filter expression
projectionExpression string
Sets the attributes that Dynomate writes for each item. In the app: Output tab › Projection expression
expressionAttributeNames map
Maps the #name placeholders in expressions to attribute names. In the app: Scope tab › Attribute name aliases
expressionAttributeValues map
Maps the :value placeholders in expressions to values, in plain or typed form. In the app: Scope tab › Attribute value aliases
snapshot boolean
If true, Dynomate also registers the export as a local snapshot that you can query, and returns its ID. The default is false. In the app: Output tab › Register as queryable snapshot