Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Sources

Connect Amazon S3 as a source

Give Artie read access to an S3 bucket, then map its CSV, JSON, Parquet or ACH files to destination tables so each new file lands as rows.

Prerequisites

  • S3 sources turned on for your company. Ask your Artie contact; self-serve and free plans can’t use S3 as a source.
  • An S3 bucket that holds the files, and its AWS Region.
  • Permission to create an IAM user or IAM role in the AWS account that owns the bucket.
  • Files you don’t want ingested moved out of the prefixes you plan to map. Artie reads every object already under a mapping’s prefix when it starts.

Grant Artie access to the bucket

Artie connects with an IAM user’s access key or by assuming an IAM role. Either identity needs this permissions policy:

JSON
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:ListAllMyBuckets",
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::BUCKET_NAME"
    },
    {
      "Effect": "Allow",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::BUCKET_NAME/*"
    }
  ]
}

Replace BUCKET_NAME with your bucket’s name. Each action covers one job:

ActionWhat Artie uses it for
s3:ListAllMyBucketsLists your buckets in the Bucket name field
s3:ListBucketLists the objects under each mapping’s prefix
s3:GetObjectReads each file

Create the identity for the authentication method you plan to use in Artie.

  1. Create an IAM user and attach the permissions policy.
  2. Create an access key for the user.

In Artie, enter the key in AWS access key ID and AWS secret access key.

Connect S3 in Artie

S3 has no Network access or Prepare source step. Each path mapping writes to a destination table, so you set up the destination before adding mappings.

  1. Choose S3

    On the home page, select New pipeline. On Choose source, select S3.

  2. Enter the connection details

    On Connect and verify, set Authentication method to the method you set up in AWS, and enter its credentials. Select the AWS region, then pick your bucket in Bucket name.

    The list shows the buckets your credentials can see. Type the name instead if your bucket isn’t listed.

  3. Verify the source

    Select Verify source. When the step shows Source verified, select Continue.

  4. Set up the destination

    On Choose tables, the Path mappings section asks for a destination first. Select Set up destination, then choose and connect your destination.

    The destination check needs at least one path mapping, so select Verify later on the destination’s Connect and verify step.

  5. Add path mappings

    In the setup sidebar, select Choose tables. Select Add path mapping, fill in the fields in Configure path mappings, and select Add mapping. Add one mapping for each group of files.

  6. Deploy the pipeline

    On Review and deploy, select Validate and deploy.

Verify the first file

Upload a file that matches one mapping, then check its destination table. Artie picks the file up on its next listing once the file is 10 seconds old. Listings run 60 seconds apart. With File path on, the artieSourcePath column holds the file’s object key.

Configure path mappings

A path mapping sends matching objects in the bucket to one destination table. Several mappings can read the same files into different tables, and several can write to one table. Nothing replicates until at least one mapping exists.

During setup, mappings are on the Choose tables step. On an existing pipeline, edit them on the pipeline page’s Path mappings tab. Changes apply after you save and deploy the pipeline.

Mapping fields

Each mapping has these fields:

FieldRequiredWhat it does
PrefixYesSelects the objects under this key prefix. A prefix without a trailing slash matches as a folder: orders matches orders/a.csv but not orders-2024.csv.
File name patternNoA regular expression matched against the base file name, after a .gz suffix is removed. Blank matches every object under the prefix.
FormatYesCSV (default), JSON, Parquet or ACH. Artie detects gzip-compressed objects and decompresses them in every format.
DestinationYesAn existing table in the destination, or Create a new table with a Table name.
Primary keyNoThe columns that uniquely identify a row. Blank keys rows by file path and line number.

File name pattern never includes the prefix. For example, ^orders-[0-9]+\.csv$ matches incoming/orders/orders-42.csv and incoming/orders/orders-42.csv.gz. Lookarounds and backreferences aren’t supported.

Two mappings can’t read the same prefix and pattern into the same table. Saving one shows These files already map to TABLE_NAME.

CSV options

CSV mappings have these extra options:

OptionWhat it does
DelimiterThe single character between fields. Default ,. It cannot be a quote, newline or carriage return.
Comment prefixSkips rows that start with this single character. It must differ from the delimiter.
HeaderColumn names for files without a header row. Empty reads the names from row 1.
Null valueValues to read as NULL, for example \N.
Trim whitespaceRemoves leading and trailing whitespace from every value.

Primary keys

Set a primary key, such as order_id, when later files restate earlier rows, as recurring snapshots do. Matching destination rows then update in place. Without a primary key, Artie keys each row by artieSourcePath and artieSourceRecordNumber, so each new file adds rows.

A mapping without a primary key needs File path and Line number turned on in Metadata columns; it won’t save otherwise. Every row needs a value in each key column, or the file fails.

Metadata columns

Metadata columns record where each row came from. Turn them on per mapping:

CheckboxColumnValueOn by default
File pathartieSourcePathThe full object keyYes
Line numberartieSourceRecordNumberThe row’s position in the file, starting at 1Yes
Ingested atartieSourceIngestedAtWhen Artie read the row, in UTCYes
File nameartieSourceFileNameThe last segment of the object keyNo
Last modifiedartieSourceLastModifiedThe object’s S3 last-modified timeNo
ETagartieSourceETagThe object’s S3 ETagNo

File requirements

Each format accepts one file shape:

FormatAccepted fileWhat becomes a row
CSVA header row, or names set in Header. Every data row has as many fields as the header.Each data row. Every value is read as a string.
JSONOne top-level array of objects, or newline-delimited JSON (NDJSON) with one object per line, up to 16 MiB per line.Each object. Nested objects and arrays are written as JSON text.
ParquetA flat schema of primitive, optional and repeated-primitive columns. Nested structs, maps and lists of structs fail the file.Each row.
ACHA structurally valid NACHA file. Artie does not check check digits or batch totals.Each entry detail record. File and batch header and control fields repeat on every row, and addenda go in an addenda column.

In a CSV file whose header has 2 or more columns, a row with a single field ends the file. Artie treats it as a trailer and skips any rows after it. An ACH file that fails to parse is rejected whole, and none of its rows are written.

Edit or remove a mapping

Keep a mapping once it has processed files. Artie stores each mapping’s progress under an ID it assigns on first save, so editing the prefix, pattern or table keeps that progress. Objects under a new prefix that are older than the checkpoint are skipped.

Removing a mapping and adding it again creates a new mapping, which re-reads every object under its prefix. Removing the last mapping for a table removes that table from the pipeline.

File processing and checkpoints

Artie lists every mapping’s prefix, processes new objects in order of last-modified time, then waits 60 seconds before listing again. It skips an object until it’s at least 10 seconds old, so an upload has time to finish.

On first start, Artie reads every object already under the mapping prefixes, then each new object as it lands. A mapping added later also starts with the objects already under its prefix.

Checkpoints and retries

Each mapping keeps its own checkpoint: the last-modified time and key of the last object it finished. Artie advances it only after the object’s rows are flushed to the destination. Artie skips objects at or before the checkpoint. An object with the same timestamp and a later key is still processed.

If an object fails to parse or flush, Artie stops reading the bucket and reports the error on the pipeline. Artie restarts reading automatically, waiting up to 5 minutes between attempts. Each time, that mapping retries the same object. Its later files wait; other mappings keep their progress.

Ingestion is at least once: after a failed flush, Artie reads the whole object again. A re-read object produces the same row keys as the first read.

Snapshots and deletes

Artie never deletes destination rows for an S3 source. It writes each parsed row as a new or updated row and never compares a file with an earlier one. A row that disappears from a later snapshot stays in the destination. Handle deletions separately when the destination must mirror them.

Schema changes

Columns come from each file’s data. A new field becomes a new column, and a renamed field arrives as a new column. Renaming files doesn’t interrupt ingestion while each file still matches its mapping’s Prefix and File name pattern.

When a destination column already exists, Artie writes values as that column’s type. A value that can’t convert, such as abc in an integer column, fails the file instead of being coerced. On Snowflake and BigQuery only, Artie can turn on a setting that writes NULL for these values instead. On Snowflake it covers bad dates, times, timestamps, numbers and booleans, except in rows that load through Snowpipe Streaming. On BigQuery it covers only bad dates, times and timestamps.

Troubleshoot S3 ingestion

These entries cover a first file that never arrives and a mapping that stops partway.

The test file doesn’t arrive

Check each of these for the file and its mapping:

  • The file is in the bucket set in Bucket name, and that bucket is in the selected AWS region.
  • Its key is under the mapping’s Prefix, and its base name matches File name pattern.
  • It’s at least 10 seconds old, and a listing has run since (one runs every 60 seconds).
  • Its last-modified time is later than the mapping’s checkpoint. An edited prefix keeps the old checkpoint.
  • The IAM user or role has the three actions in Grant Artie access to the bucket.
  • For an object encrypted with a customer-managed AWS KMS key, the identity has kms:Decrypt on the key, and the key policy allows it.

If every check passes, open the pipeline’s errors and alerts in Artie. A file that fails stops ingestion with an error that names its mapping and object key, as shown in Later files stop arriving for one mapping.

Later files stop arriving for one mapping

Cause: One object failed to parse or flush. Artie stops reading the bucket and retries that object each time reading restarts, so its mapping doesn’t move past it. The pipeline’s error names the mapping ID and the object key:

Text
S3 consumer stopped: mapping "4f1c9a2e-7b3d-4e8a-9c61-2d5f0b8e1a37" object "incoming/orders/orders-42.csv": row 3 has 4 fields, expected 5

Common errors that stop a file:

ErrorCause
row N has X fields, expected YA CSV data row has a different field count from the header
duplicate header column "NAME"A CSV header repeats a column name
primary key "COLUMN" is missing or nilA row has no value in a primary key column
parquet column "NAME" is a nested groupThe Parquet file has a nested column
ach: read file: ...The ACH file is structurally invalid

Fix: Correct the file and upload it under a new key, then move the failed object out of the mapping’s prefix. Artie retries only objects it still lists.

Verify: After the next listing, the mapping’s later files arrive in the destination table.

Was this page helpful?