Amazon S3 Sink Connector for Confluent Cloud

Note

If you are installing the connector locally for Confluent Platform, see Amazon S3 Sink Connector for Confluent Platform.

You can use the Kafka Connect Amazon S3 sink connector to export data from Apache Kafka® topics to S3 objects in either Avro, JSON, or Bytes formats. Depending on your environment, the S3 connector can export data by guaranteeing exactly-once delivery semantics to consumers of the S3 objects it produces.

The Amazon S3 sink connector periodically polls data from Kafka and in turn uploads it to S3. A partitioner is used to split the data of every Kafka partition into chunks. Each chunk of data is represented as an S3 object. The key name encodes the topic, the Kafka partition, and the start offset of this data chunk. If no partitioner is specified in the configuration, the default partitioner which preserves Kafka partitioning is used. The size of each data chunk is determined by the number of records written to S3 and by schema compatibility.

Features

The Amazon S3 Sink connector for Confluent Cloud provides the following features:

  • Exactly Once Delivery: Records that are exported using a deterministic partitioner are delivered with exactly-once semantics regardless of the eventual consistency of S3.
  • Data Format with or without Schema: Out of the box, the connector supports writing data to S3 in Avro, JSON, and Bytes. Schema validation is disabled for JSON.
  • Schema Evolution: schema.compatibility is set to NONE.
  • Partitioner: The connector supports the TimeBasedPartitioner class based on the Kafka class TimeStamp.
  • Flush size: flush.size defaults to 1000. For example, if you use the default setting of 1000 and your topic has six partitions, files start to be created in the storage bucket after more than 1000 records exist in each partition. Note that the default value of 1000 can be increased if needed.

Refer to Confluent Cloud connector limitations for additional information.

S3 Bucket Policy

The AWS account accessing the S3 bucket must have the following permissions:

  • ListAllMyBuckets
  • ListBucket
  • GetBucketLocation
  • PutObject
  • GetObject
  • AbortMultipartUpload
  • ListMultipartUpload
  • ListMultipartUploadParts
  • ListBucketMultipartUploads

You can copy the following JSON when creating the bucket policy. Change <bucket-name> to a real bucket name. For more information, see How Do I Add an S3 Bucket Policy.

{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListAllMyBuckets"
         ],
         "Resource":"arn:aws:s3:::*"
      },
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListBucket",
            "s3:GetBucketLocation"
         ],
         "Resource":"arn:aws:s3:::<bucket-name>"
      },
      {
         "Effect":"Allow",
         "Action":[
            "s3:PutObject",
            "s3:GetObject",
            "s3:AbortMultipartUpload",
            "s3:ListMultipartUploadParts",
            "s3:ListBucketMultipartUploads"

         ],
         "Resource":"arn:aws:s3:::<bucket-name>/*"
      }
   ]
}

Quick Start

Use this quick start to get up and running with the Confluent Cloud S3 sink connector. The quick start provides the basics of selecting the connector and configuring it to stream events to an S3 bucket.

Prerequisites

Step 1: Launch your Confluent Cloud cluster.

See the Confluent Cloud Quick Start for installation instructions.

Step 2: Add a connector.

Click Connectors > Add connector.

../../_images/ccloud-add-connector.png

Step 3: Select your connector.

Click the Amazon S3 Sink connector icon.

Step 4: Enter the connector details.

Note

Make sure you have all your prerequisites completed.

Complete the following and click Continue.

  1. Enter a Connector Name.

  2. Enter your Kafka Cluster credentials. The credentials are either the API key and secret or the service account API key and secret.

  3. Enter one or more Topic names. Separate multiple topic names with a comma.

    ../../_images/ccloud-s3-details.png

Step 5: Enter the destination details.

Complete the following and click Continue.

Important

Your AWS credentials and bucket name are validated here. Make sure you enter these correctly.

  1. Enter your AWS credentials.

  2. Enter the S3 bucket name.

  3. Select the message format. Note that you have to have Confluent Cloud Schema Registry configured if using a schema-based message format (like Avro). See Managing Schemas for Topics in Confluent Cloud.

  4. Select the Time interval that sets how you want your messages grouped in the S3 bucket. For example, if you select Hourly, messages are grouped into folders for each hour data is streamed to the bucket.

  5. Enter the Flush size. This value defaults to 1000. For example, if you use the default setting of 1000 and your topic has six partitions, files start to be created in the storage bucket after more than 1000 records exist in each partition. Note that the default value of 1000 can be increased if needed.

  6. Enter the number of tasks in use by the connector. Do not enter a value that exceeds the Max number displayed.

    ../../_images/ccloud-s3-bucket-destination.png

Step 6: Launch the connector.

Verify the following and click Launch.

  1. Make sure your data is going to the correct bucket.

  2. Check that the last directory in the path shown is using the Time Interval you entered earlier.

    ../../_images/ccloud-s3-launch-connector.png

Step 7: Check the connector status.

The status for the connector should go from Provisioning to Running.

../../_images/ccloud-s3-status.png

Step 8: Check the S3 bucket.

  1. Go to the AWS Management Console and select Storage > S3.

  2. Open your S3 bucket.

  3. Open your topic folder and each subsequent folder until you see your messages displayed.

    ../../_images/ccloud-aws-s3-details.png

For additional information about the S3 connector see Amazon S3 Sink Connector for Confluent Platform. Note that not all Confluent Platform S3 connector features are provided in the Confluent Cloud S3 connector.

Next Steps

Try out a Confluent Cloud demo. Use the Confluent Cloud S3 sink connector and an AWS S3 bucket to store data.