Set up an Amazon S3 Tables destination¶
SQDR replicates to Amazon S3 Tables (Apache Iceberg tables in an S3 table bucket) through a Stelo Capture Apply
extension, AwsApplyProcessor. At each baseline it creates the Iceberg table through the S3 Tables Iceberg REST
endpoint; it then sends the rows and changes as JSON records to an Amazon Data Firehose stream, which writes them
to the table. It signs in to AWS with an IAM user's access key.
Supported configurations¶
| Supported | |
|---|---|
| Service | Amazon S3 Tables, written through Amazon Data Firehose with the Apache Iceberg Tables destination, in a region that has both (see Regions). |
| Connection | The Apply extension runs in Stelo Capture and calls AWS over HTTPS. There's no ODBC driver: the destination has no connection of its own (see ODBC and Java connectors). |
| Replication | Incremental groups and snapshot subscriptions. A snapshot or baseline runs through the source's Capture Agent, so the source needs one. |
| Apply method | Merge only (see Destinations and methods). |
| Authentication | An IAM user's access key and secret key. |
| Encryption | HTTPS to AWS. Encryption at rest is set on the table bucket. |
Firewall rules on the Stelo VM¶
The Stelo VM calls the region's S3 Tables endpoint (s3tables.<region>.amazonaws.com) and Firehose endpoint
over HTTPS (port 443).
How it works¶
- Namespace and table. A subscription's destination schema is the Iceberg namespace, and its destination table the Iceberg table, both in lowercase; column names are lowercased too.
- Baseline. Each baseline drops the table (with its data) if it exists, creates it again from the subscription's
columns, and sends every row as an
insertrecord. The key columns are required and become the table's identifier fields; the other columns are optional. The namespace isn't created: it must exist. - Changes. Inserts, updates and deletes at the source are sent as
insert,updateanddeleterecords (for a member that archives changes, all asinsert). Each record holds the column values and the fields_database(the namespace),_table_nameand_operation, which tell Firehose where and how to write it. - Firehose buffers the records and writes them to the tables. The extension sends up to 500 records (4 MB) per call, on up to poolSize calls at once, and retries records Firehose throttles.
Prepare AWS¶
Table bucket and namespace¶
- Create a table bucket in the region you want. Note its ARN, of the form
arn:aws:s3tables:<region>:<account-id>:bucket/<bucket-name>. -
Create a namespace for each destination schema you'll use, named as the schema in lowercase. Namespace and table names are 1 to 255 characters: lowercase letters, numbers and underscores, starting with a letter or number; a namespace can't start with
aws. For example, with the AWS CLI:aws s3tables create-namespace --table-bucket-arn arn:aws:s3tables:us-east-1:111122223333:bucket/sqdr-bucket --namespace sales
Firehose stream¶
Firehose writes to S3 Tables through the AWS Glue Data Catalog. Following the AWS documentation (see Related):
- Integrate the table bucket with AWS analytics services, which creates the
s3tablescatalogcatalog in AWS Glue. - Create an IAM role for Firehose with access to the table bucket and the catalog (AWS lists the S3 Tables, Glue, S3 error bucket and CloudWatch Logs permissions it needs), and, if you use AWS Lake Formation, grant the role access to the tables.
- Create the Firehose stream with source Direct PUT and destination Apache Iceberg Tables, in the table
bucket's region, with that role and the bucket's catalog. Have it route each record by its own fields: the database
(namespace) from
_database, the table from_table_name, and the operation from_operation. Give it an S3 bucket for records it can't deliver.
Use one stream per destination: AWS doesn't recommend several streams writing to the same table.
IAM user for Stelo Capture¶
Create an IAM user for Stelo Capture, give it this policy, and create an access key for it. Replace the region, account, bucket name and stream name:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3tables:GetTableBucket",
"s3tables:ListNamespaces",
"s3tables:CreateTable",
"s3tables:PutTableData",
"s3tables:DeleteTable"
],
"Resource": [
"arn:aws:s3tables:us-east-1:111122223333:bucket/sqdr-bucket",
"arn:aws:s3tables:us-east-1:111122223333:bucket/sqdr-bucket/table/*"
]
},
{
"Effect": "Allow",
"Action": [
"firehose:PutRecordBatch",
"firehose:DescribeDeliveryStream"
],
"Resource": "arn:aws:firehose:us-east-1:111122223333:deliverystream/sqdr-stream"
}
]
}
Stelo Capture uses the access key itself; it can't assume an IAM role. Store the access key ID and secret access key as
secrets and enter their references ($$name$$) as accessKey and secretKey (see
Rotate the access key). What each action is for: see IAM permissions.
Network and region¶
The table bucket, the stream and the destination's region must be the same. The Firehose Iceberg destination isn't available in every region; check the AWS documentation for yours.
IAM permissions¶
| Action | Why |
|---|---|
s3tables:GetTableBucket |
The Iceberg REST catalog reads its configuration when the extension connects. |
s3tables:ListNamespaces |
Verify counts the bucket's namespaces. |
s3tables:CreateTable, s3tables:PutTableData |
Each baseline creates the table. |
s3tables:DeleteTable |
Each baseline first drops the table. |
firehose:PutRecordBatch |
Sends the records. |
firehose:DescribeDeliveryStream |
Verify checks the stream. |
Rotate the access key¶
Incremental groups keep their own copy of the destination's parameters, but that copy holds only the references: to rotate the key, change the secrets' values, and every group uses them. If you entered the values themselves, change them in the destination and in each group's Parameters (reload them with Load from Destination; see Group properties).
Create the destination¶
- Name (see Create a destination): choose the DBMS Type S3tables.
- The Connector step has no template for this DBMS type: save the destination.
-
In the destination's Default Parameters (on its Advanced tab), choose the
classNamecom.starquest.sqdr.apply.aws.AwsApplyProcessorand fill in:Parameter What to enter regionThe AWS region of the table bucket and the stream, for example us-east-1.accessKeyThe IAM user's access key ID, or a secret reference ( $$name$$).secretKeyThe secret access key, or a secret reference ( $$name$$).bucketARNThe table bucket's ARN. streamNameThe Firehose stream's name. poolSizeHow many record batches are sent to Firehose at once. 10 by default. In Raw, for example:
className=com.starquest.sqdr.apply.aws.AwsApplyProcessor region=us-east-1 accessKey=$$S3TABLES_ACCESS_KEY$$ secretKey=$$S3TABLES_SECRET_KEY$$ bucketARN=arn:aws:s3tables:us-east-1:111122223333:bucket/sqdr-bucket streamName=sqdr-stream poolSize=10 -
Under Defaults, set Object Schema to the namespace new subscriptions should use (see Defaults).
- Click Save.
Test the connection. S3 Tables destinations have no Verify in 7.0. The first baseline tests the parameters: it creates the table through the S3 Tables endpoint and sends the rows to Firehose (see Check the destination).
Group settings for Amazon S3 Tables¶
When you create an incremental group to this destination:
- Destination schema. Set the group's destination schema (its members' default) to the namespace. It's used in lowercase, and the namespace must already exist in the table bucket (see Table bucket and namespace).
- Parameters. The group copies the destination's Default Parameters when it's created and keeps its own copy. Check the region, the access key, the bucket ARN and the stream name there (see Source/Destination). If you changed the destination after creating the group, use Load from Destination.
- DML Replication is always Merge.
- Every member needs a key (see Limitations).
Check the destination¶
After the incremental group's first baseline (for snapshots, after the first run):
- Group status. On the Groups page, the group shows Actively monitoring and applying change data (see Group status).
- Rows at the destination. In the S3 console, check that the table appears in the namespace. After Firehose has
delivered the records (it buffers them first), query the table, for example with Amazon Athena through the
s3tablescatalogcatalog, and compare its row count with the source. - Changes. Change a row at the source and check that it arrives after the group's next poll (the Poll Interval; see Scheduling) and Firehose's buffering. Records Firehose can't deliver go to the stream's error bucket, with the reason.
Data types¶
Columns get Iceberg types: boolean, int (also for TINYINT and SMALLINT sources), long, float, double,
decimal(p,s) (a decimal without a precision becomes double), string (character data and other types), binary,
date, time, timestamp and timestamptz. Binary values are sent as Base64 text. A floating-point key column
becomes string, because Iceberg identifier fields can't be floating-point. See
Data type mapping.
Limitations¶
- Every baseline replaces the table, data included.
- Column changes aren't applied to an existing table: the columns are set when a baseline creates it. After you add or change columns at the source, run a baseline of the member.
- A key is needed: a subscription without one is refused when it's saved (see Keys and indexes).
- Record size. A row larger than 1,000 KB as JSON (Firehose's limit) stops the apply with "Record for table ... exceeds 1,000 KiB". Large LOB columns can reach it.
- Names must fit the S3 Tables rules (see Table bucket and namespace); hyphens and periods aren't allowed.
- Truncates at the source aren't applied.
Troubleshooting¶
Problems and messages, with their causes and fixes, are in Troubleshooting › Cloud and streaming destinations.
Related¶
- Destinations and The Connector step
- Destination properties: Default Parameters
- AWS: Amazon S3 Tables, Integrating table buckets with AWS analytics services, Accessing tables using the S3 Tables Iceberg REST endpoint
- AWS: Deliver data to Apache Iceberg Tables with Amazon Data Firehose, Considerations and limitations, Controlling access with Amazon Data Firehose