Amazon S3 Source Connector for Confluent Cloud¶
Note
If you are installing the connector locally for Confluent Platform, see Generalized Amazon S3 Source Connector for Confluent Platform.
The fully-managed Amazon S3 Source connector reads data from files in an S3 bucket. The file names don’t have to be in a specific format. The file format has to be supported (for example, JSON, Avro and Byte Array) for the connector to read from.
Features¶
The Amazon S3 Source connector provides the following features:
- At least once delivery: The connector guarantees that records are delivered at least once.
- Supports multiple tasks: The connector supports running one or more tasks.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.
Refer to Confluent Cloud connector limitations for additional information.
IAM Policy for S3¶
The AWS user account accessing the S3 bucket must have the following permissions:
- ListBucket
- GetObject
Note
This is the IAM policy for the user account and not a bucket policy.
For more information, see Create and attach a policy to an IAM user.
Quick Start¶
Use this quick start to get up and running with the Confluent Cloud Amazon S3 Source connector. The quick start provides the basics of selecting the connector and configuring it to get files from an Amazon S3 bucket.
- Prerequisites
- Authorized access to a Confluent Cloud cluster on Amazon Web Services (AWS), Microsoft Azure (Azure), or Google Cloud Platform (GCP).
- The Confluent CLI installed and configured for the cluster. See Install the Confluent CLI.
- Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf). See Environment Limitations for additional information.
- An Amazon S3 bucket in the same region as your Confluent Cloud cluster.
- For networking considerations, see Networking and DNS Considerations. To use static egress IPs, see Static Egress IP Addresses.
- An AWS IAM Policy for S3 configured for bucket access.
- An AWS account configured with Access Keys. You use these access keys when setting up the connector.
- Kafka cluster credentials. The following lists the different ways you can provide credentials.
- Enter an existing service account resource ID.
- Create a Confluent Cloud service account for the connector. Make sure to review the ACL entries required in the service account documentation. Some connectors have specific ACL requirements.
- Create a Confluent Cloud API key and secret. To create a key and secret, you can use confluent api-key create or you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.
- Confluent Cloud Schema Registry must be enabled for your cluster, if you are using a messaging schema (like Apache Avro). See Working with schemas.
Using the Confluent Cloud Console¶
Step 1: Launch your Confluent Cloud cluster.¶
See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.
Step 2: Add a connector.¶
In the left navigation menu, click Data integration, and then click Connectors. If you already have connectors in your cluster, click + Add connector.
Step 4: Enter the connector details.¶
Note
- Make sure you have all your prerequisites completed.
- An asterisk ( * ) designates a required entry.
Complete the following and click Next.
- Enter a Connector Name.
- Enter the Topic Name Pattern. A list of topics along with a regex expression of the files which are to be sent to that topic. For example: Using
"my-topic:.*"
sends all files to"my-topic"
, while an expression such as"special-topic:foo+*
” will send only files starting with"foo"
to"special-topic"
. - Select the way you want to provide Kafka Cluster credentials. You can either select a service account resource ID or you can enter an API key and secret (or generate these in the Cloud Console).
- Select an Input message format: Supports AVRO, JSON (schemaless), or BYTES. A valid schema must be available in Schema Registry to use a schema-based message format, like Avro.
- Select an Output Message Format: Defaults to the file format selected for the input message format. AVRO, BYTES, JSON, JSON_SR, PROTOBUF, and STRING. A valid schema must be available in Schema Registry if using a schema-based format.
- Enter your AWS credentials. For information about how to set these up, see Access Keys.
Step 5: Enter the S3 bucket details.¶
- Enter the S3 bucket name.
- Enter the AWS Region where the bucket is located.
- Enter the Number of Retries on S3 Errors. The number of times a single S3 API call should be retried when it fails with a retriable error (such as a throttling exception). Once this limit is exceeded, the Connect poll itself may retry (based on the Connect-based retry configuration).
- Enter the Retry Backoff on S3 Errors in milliseconds. This sets how many milliseconds to wait before attempting the first retry of a failed S3 request. Upon a failure, this connector may wait up to twice as long as the previous wait, up to the maximum number of retries. This avoids retrying in a tight loop under failure scenarios.
- Select whether to use an S3 Accelerated Endpoint (see S3 Transfer Acceleration). Defaults to NO.
- Select whether to use S3 Path-style Access. Defaults to NO.
- Select whether to Send S3 Expect Continue Request. Enable or disable the HTTP/1.1 handshake using
EXPECT: 100-CONTINUE
during a multi-part upload. If YES, the client waits for a100 (CONTINUE)
response before sending the request body. If NO, the client uploads the entire request body without checking if the server is willing to accept the request. - Select the S3 Server Side Encryption Algorithm. Defaults to NONE.
- Enter a customer-provided server-side encryption key (SSE-C).
Step 6: Enter storage and other details.¶
- Enter a Topics directory. This is a top-level directory name where data is stored in the S3 bucket. Defaults to
topics
. - Enter a Task Batch Size: The number of files assigned to each task at a time. Defaults to
10
. The maximum value supported is2000
and the minimum value is1
. - Enter a File Discovery Starting Timestamp. A UNIX timestamp (i.e., seconds since Jan 1, 1970 UTC) that denotes where to start processing files. The connector ignores any file encountered having an earlier creation time.
- Enter a Directory Delimiter Character. The pattern to use as the delimiter character for directories. Defaults to
/
. - Select the Behavior on Errors. Defaults to
FAIL
. - Select a Byte Array Line Separator. String inserted between records when using ByteArrayFormat. Defaults to
\\n
and may contain escape sequences like\\n
. An input record that contains the line separator looks like multiple records in the storage object input. - Enter an S3 poll interval in milliseconds (ms). Defaults to
60000
ms (one minute). - Set the Max records per poll. The maximum amount of records to return each time the connector polls storage. Defaults to
200
. The maximum value supported is10000
and the minimum value is1
. - Enter the maximum number of tasks. The connector supports running one or more tasks. More tasks may improve performance.
Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.
For configuration property values and descriptions, see Configuration Properties.
Step 7: Launch the connector.¶
Verify the following and click Launch.
Step 8: Check the connector status.¶
The status for the connector should go from Provisioning to Running.
Step 9. Check the Kafka topic.¶
After the connector is running, verify that records are populating the Kafka topic.
Note
The S3 Source connector loads and filters all object names in the bucket
before it starts sourcing records. When starting up, the connector may
display RUNNING
but not show any throughput. This is because bucket
loading is not finished. For buckets with a large amount of objects, bucket
loading can take several minutes to complete.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.
See also
For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.
Using the Confluent CLI¶
Complete the following steps to set up and run the connector using the Confluent CLI.
Note
- Make sure you have all your prerequisites completed.
- The example commands use Confluent CLI version 2. For more information see, Confluent CLI v2.
Step 1: List the available connectors.¶
Enter the following command to list available connectors:
confluent connect plugin list
Step 2: Show the required connector configuration properties.¶
Enter the following command to show the required connector properties:
confluent connect plugin describe <connector-catalog-name>
For example:
confluent connect plugin describe S3Source
Example output:
The following are required configs:
connector.class : S3Source
name
topic.regex.list
kafka.api.key : ["kafka.api.key" is required when "kafka.auth.mode==KAFKA_API_KEY"]
kafka.api.secret : ["kafka.api.secret" is required when "kafka.auth.mode==KAFKA_API_KEY" "kafka.api.secret" is required]
input.data.format
output.data.format
aws.access.key.id
aws.secret.access.key
s3.bucket.name
tasks.max
Step 3: Create the connector configuration file.¶
Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.
{
"connector.class": "S3Source",
"name": "S3SourceConnector_0",
"topic.regex.list": "topics",
"kafka.auth.mode": "SERVICE_ACCOUNT",
"kafka.service.account.id": "<service-account-resource-ID>",
"input.data.format": "JSON",
"output.data.format": "BYTES",
"aws.access.key.id": "<access-key>",
"aws.secret.access.id": "<secret-access-id>",
"s3.bucket.name": "<bucket-name>",
"tasks.max": "1",
}
Note the following required property definitions:
"connector.class"
: Identifies the connector plugin name."name"
: Sets a name for your new connector."topic.regex.list"
:
"kafka.auth.mode"
: Identifies the connector authentication mode you want to use. There are two options:SERVICE_ACCOUNT
orKAFKA_API_KEY
(the default). To use an API key and secret, specify the configuration propertieskafka.api.key
andkafka.api.secret
, as shown in the example configuration (above). To use a service account, specify the Resource ID in the propertykafka.service.account.id=<service-account-resource-ID>
. To list the available service account resource IDs, use the following command:confluent iam service-account list
For example:
confluent iam service-account list Id | Resource ID | Name | Description +---------+-------------+-------------------+------------------- 123456 | sa-l1r23m | sa-1 | Service account 1 789101 | sa-l4d56p | sa-2 | Service account 2
"input.data.format"
: Supports AVRO, JSON (schemaless), or BYTES. A valid schema must be available in Schema Registry to use a schema-based message format, like Avro."output.data.format"
: Defaults to the file format selected for the input data format. AVRO, BYTES, JSON, JSON_SR, PROTOBUF, and STRING. A valid schema must be available in Schema Registry if using a schema-based format."tasks.max"
: The total number of tasks to run in parallel. More tasks may improve performance.Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.
For configuration property values and descriptions, see Configuration Properties.
Step 4: Load the properties file and create the connector.¶
Enter the following command to load the configuration and start the connector:
confluent connect create --config <file-name>.json
For example:
confluent connect create --config s3-source-config.json
Example output:
Created connector S3SourceConnector_0 lcc-ix4dl
Step 5: Check the connector status.¶
Enter the following command to check the connector status:
confluent connect list
Example output:
ID | Name | Status | Type
+-----------+-----------------------+---------+------+
lcc-ix4dl | S3SourceConnector_0 | RUNNING | source
Step 6. Check the Kafka topic.¶
After the connector is running, verify that records are populating the Kafka topic.
Note
The S3 Source connector loads and filters all object names in the bucket
before it starts sourcing records. When starting up, the connector may
display RUNNING
but not show any throughput. This is because bucket
loading is not finished. For buckets with a large amount of objects, bucket
loading can take several minutes to complete.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.
Configuration Properties¶
Use the following configuration properties with this connector.
How should we connect to your data?¶
name
Sets a name for your connector.
- Type: string
- Valid Values: A string at most 64 characters long
- Importance: high
Which topic(s) do you want to send data to?¶
topic.regex.list
A list of topics along with a regex expression of the files which are to be sent to that topic. For example: “my-topic:.*” will send all files to “my-topic”, while a list containing only the expression “special-topic:.*.json” will send only files starting with “.json” to “special-topic”, and all other files not matching any patterns will be ignored and not sourced. Files that match multiple mappings will be sent to the first topic in the list that maps the file.
- Type: list
- Importance: high
Kafka Cluster credentials¶
kafka.auth.mode
Kafka Authentication mode. It can be one of KAFKA_API_KEY or SERVICE_ACCOUNT. It defaults to KAFKA_API_KEY mode.
- Type: string
- Default: KAFKA_API_KEY
- Valid Values: KAFKA_API_KEY, SERVICE_ACCOUNT
- Importance: high
kafka.api.key
- Type: password
- Importance: high
kafka.service.account.id
The Service Account that will be used to generate the API keys to communicate with Kafka Cluster.
- Type: string
- Importance: high
kafka.api.secret
- Type: password
- Importance: high
Input and output messages¶
input.data.format
Sets the input message format. Valid entries are AVRO, JSON, or BYTES. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO.
- Type: string
- Valid Values: AVRO, BYTES, JSON
- Importance: high
output.data.format
Set the output message format for values. Valid entries are AVRO, JSON, JSON_SR, PROTOBUF, STRING, or BYTES. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO, JSON_SR and PROTOBUF. If no value for this property is provided, the value specified for the ‘input.data.format’ property is used.
- Type: string
- Valid Values: AVRO, BYTES, JSON, JSON_SR, PROTOBUF, STRING
- Importance: high
AWS credentials¶
aws.access.key.id
The AWS Access Key used to connect to Amazon S3.
- Type: password
- Importance: high
aws.secret.access.key
The AWS Secret Key used to connect to Amazon S3.
- Type: password
- Importance: high
How should we connect to your S3 bucket?¶
s3.bucket.name
- Type: string
- Importance: high
s3.region
Set to the AWS region where your S3 bucket resides.
- Type: string
- Importance: high
s3.part.retries
The number of times a single S3 API call should be retried in the case that it fails with a “retiable” error (such as a throttling exception). Once this limit is exceeded, the Kafka Connect poll itself may retry (based upon the Kafka Connect-based retry configuration).
- Type: int
- Default: 3
- Importance: medium
s3.retry.backoff.ms
How long to wait in milliseconds before attempting the first retry of a failed S3 request. Upon a failure, this connector may wait up to twice as long as the previous wait, up to the maximum number of retries. This avoids retrying in a tight loop under failure scenarios.
- Type: int
- Default: 200
- Importance: medium
ui.s3.wan.mode
Use an S3 accelerated endpoint.
- Type: string
- Default: NO
- Valid Values: NO, YES
- Importance: medium
ui.s3.path.style.access
Whether to use s3 path-style access.
- Type: string
- Default: NO
- Valid Values: NO, YES
- Importance: medium
s3.http.send.expect.continue
Enable/disable use of the HTTP/1.1 handshake using EXPECT: 100-CONTINUE during multi-part upload. If true, the client waits for a 100 (CONTINUE) response before sending the request body. If false, the client uploads the entire request body without checking if the server is willing to accept the request.
- Type: string
- Default: YES
- Valid Values: NO, YES
- Importance: medium
ui.s3.ssea.name
The S3 server-side encryption algorithm.
- Type: string
- Default: NONE
- Valid Values: AES256, AWS:KMS, NONE
- Importance: medium
s3.sse.customer.key
The S3 Server-Side Encryption customer-provided key (SSE-C).
- Type: password
- Importance: medium
Storage¶
topics.dir
Top-level directory (in the S3 bucket) where data to be ingested is stored.
- Type: string
- Default: topics
- Importance: high
task.batch.size
The number of files assigned to each task at a time
- Type: int
- Default: 10
- Valid Values: [1,…,2000]
- Importance: high
file.discovery.starting.timestamp
A unix timestamp (seconds since Jan 1, 1970 UTC) that denotes where to start processing files. Any file encountered with a creation time earlier than this will be ignored.
- Type: long
- Default: 0
- Importance: high
directory.delim
Directory delimiter pattern.
- Type: string
- Default: /
- Importance: medium
ui.behavior.on.error
Error handling behavior setting for storage connectors. Must be configured to one of the following: IGNORE, FAIL
- Type: string
- Default: FAIL
- Valid Values: FAIL, IGNORE
- Importance: medium
format.bytearray.separator
String inserted between records for ByteArrayFormat. Defaults to n and may contain escape sequences like n. An input record that contains the line separator looks like multiple records in the storage object input.
- Type: string
- Importance: medium
Data polling policy¶
s3.poll.interval.ms
Frequency in milliseconds to poll for new or removed folders. This may result in updated task configurations starting to poll for data in added folders or stopping polling for data in removed folders
- Type: long
- Default: 60000 (1 minute)
- Valid Values: [1000,…]
- Importance: medium
record.batch.max.size
The maximum amount of records to return each time storage is polled.
- Type: int
- Default: 200
- Valid Values: [1,…,10000]
- Importance: medium
Number of tasks for this connector¶
tasks.max
The total number of tasks to run in parallel.
- Type: int
- Valid Values: [1,…,1000]
- Importance: high
Next Steps¶
See also
For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.