Amazon S3
The Amazon S3 target writes data to Amazon S3. For information about supported versions, see Supported systems and versions.
To write data to an Amazon Kinesis Firehose delivery system, use the Kinesis Firehose target. To write data to Amazon Kinesis Streams, use the Kinesis Producer target.
With the Amazon S3 target, you configure the region, bucket, and common prefix to define where to write objects. You configure the authentication method that the target uses to connect to Amazon S3. You can also use a connection to configure the target.
You can use a partition prefix to specify the S3 partition to write to. You can configure a prefix and suffix for the object name, and a time basis and data time zone for the stage. You can also configure the target to add tags to the Amazon S3 objects that it creates.
The Amazon S3 target can write data asynchronously to improve performance when writing to multiple prefixes. You can configure advanced properties to tune performance.
You can configure the target to use Amazon Web Services server-side encryption to protect the data written to Amazon S3. You can also use a proxy user and compress data with gzip when writing to Amazon S3.
The Amazon S3 target creates an object for each batch of data written to Amazon S3.
The target can generate events for an event stream. For more information about the event framework, see Dataflow triggers overview.
Authentication method
You can configure the Amazon S3 target to authenticate with Amazon Web Services (AWS) using an instance profile, environment variables, credential process profile, or AWS access keys. When accessing a public bucket, you can connect anonymously using no authentication.
For more information about the authentication methods and details on how to configure each method, see Security in Amazon stages.
Bucket
When you configure the bucket where records should be written, you can specify an exact bucket name or you can use an expression that evaluates to a bucket name.
For example, to write to buckets based on data in the Type field, you can use the
following expression to define the bucket: ${record:value('/Type)}.
With this expression, the target writes records to buckets based on the data in the Type field. If an expression evaluates to a bucket that does not exist, the target handles the record based on the error handling configured in the stage.
If you use datetime variables in the expression, be sure to configure the time basis for the stage.
Partition prefix
You can use a partition prefix to organize objects by partitions. You can use the partition prefix to write to existing partitions or to create new partitions as needed. When a partition specified in the partition prefix does not exist, the target creates the partition.
You can specify an exact partition name for the partition prefix, or you can use an expression that evaluates to a partition name.
For example, to write to partitions based on data in the Country field, you can use the
following expression as the partition prefix:
${record:value('/Country')}.
With this expression, the target writes records to partitions based on the country data in the record, and creates partitions for countries that do not already have a partition.
If you use datetime variables in the expression, be sure to configure the time basis for the stage. You might also need to configure the Data Time Zone property.
Time basis and data time zone for time-based buckets and partition prefixes
The time basis and the data time zone comprises the time used by the Amazon S3 target to write records to a time-based bucket or partition prefix. When the configured bucket or partition prefix does not include time-based functions, you can ignore the time basis property.
A bucket or partition prefix has a time component when it includes datetime variables,
such as ${YYYY()} or ${DD()}, or when it includes an
expression that evaluates to a datetime value, such as
${record:valueOrDefault("/Timestamp")}.
For details about datetime variables, see Datetime variables.
- Processing Time
- When you use processing time as the time basis, the target performs
writes based on the processing time and the configured bucket and partition
prefix. The processing time is the time associated with the Data Collector running the flow, by default. You can specify a different time zone
by configuring the Data Time Zone property. To use the processing time as
the time basis, use the following expression:
This is the default time basis.${time:now()} - Record Time
- When you use the time associated with a record as the time basis, you specify a date field in the record. The target writes data based on the datetimes associated with the records, adjusting for the value specified for the Data Time Zone property.
logs-${YYYY()}-${MM()}-${DD()}If you use the time of processing as the time basis, the target writes records to partitions based on when it processes each record. If you use the time associated with the data, such as a transaction timestamp, then the target writes records to the partitions based on that timestamp. If a partition does not exist, the target creates the needed partition.
${YYYY()}-${MM()}If you use the time of processing as the time basis, the target writes records to buckets based on when it processes each record. If you use the time associated with the data, such as a transaction timestamp, then the target writes records to the buckets based on that timestamp. If a bucket does not exist, the target handles the record based on the error record handling configured for the stage.
Object names
<prefix>-<UTC timestamp>-<counter>For example: sdc-1462405014177-1.
You configure the object name prefix.
The UTC timestamp is the time when the object is created, to the millisecond. The counter is used when multiple objects are created in the same millisecond.
<prefix>-<UTC timestamp>-<counter>.<optional suffix>For example: sdc-1462405014177-1.txt.
Whole file names
<prefix>-<results of the file name expression>Add tags to objects
You can configure the Amazon S3 target to add tags to the Amazon S3 objects that it creates. Tags are key-value pairs that you can use to categorize objects, such as product: <product>.
You can configure multiple tags. When you configure a tag, you can define a tag with just the key or specify a key and value.
For more information about tags, including Amazon S3 restrictions, see the Amazon S3 documentation.
Event generation
The Amazon S3 target can generate events that you can use in an event stream. When you enable event generation, the Amazon S3 target generates event records each time after writing to an object or streaming a whole file.
- With the Amazon S3 executor to add metadata to closed objects or whole files after receiving an event.
- With the Email executor to send a custom email
after receiving an event.
For an example, see Sending email during flow processing.
- With a target to store event information.
For an example, see Preserving an audit trail of events.
For more information about dataflow triggers and the event framework, see Dataflow triggers overview.
Event records
| Record Header Attribute | Description |
|---|---|
| sdc.event.type | Event type. Uses one of the following types:
|
| sdc.event.version | Integer that indicates the version of the event record type. |
| sdc.event.creation_timestamp | Epoch timestamp when the stage created the event. |
- Object written
- The target generates an object written event record when it completes writing to an object.
- Whole file processed
- The target generates an event record when it completes streaming a
whole file. Whole file event records have the
sdc.event.typerecord header attribute set towholeFileProcessedand include the following fields:Field Description sourceFileInfo A map of attributes about the original whole file that was processed. The attribute names depend on the information provided by the source system.
targetFileInfo A map of attributes about the whole file written to the target system. The attributes include: - bucket - The bucket where the whole file is written.
- objectKey - The object key name that was written.
checksum Checksum generated for the written file. Included only when you configure the target to include checksums in the event record.
checksumAlgorithm Algorithm used to generate the checksum. Included only when you configure the target to include checksums in the event record.
Server-side encryption
You can configure the stage to use Amazon Web Services server-side encryption (SSE) to protect data written to Amazon S3. When configured for server-side encryption, the stage passes required server-side encryption configuration values to Amazon S3. Amazon S3 uses the values to encrypt the data as it is written to Amazon S3.
- Amazon S3-Managed Encryption Keys (SSE-S3)
- When you use server-side encryption with Amazon S3-managed keys, Amazon S3 manages the encryption keys for you.
- AWS KMS-Managed Encryption Keys (SSE-KMS)
- When you use server-side encryption with AWS Key Management Service (KMS), you specify the Amazon resource name (ARN) of the AWS KMS encryption key that you want to use. You can also specify key-value pairs to use for the encryption context.
- Customer-Provided Encryption Keys (SSE-C)
- When you use server-side encryption with customer-provided keys, you specify
the following information:
- Base64 encoded 256-bit encryption key
- Base64 encoded 128-bit MD5 digest of the encryption key using RFC 1321
For more information about using server-side encryption to protect data in Amazon S3, see the Amazon S3 documentation.
Data formats
The Amazon S3 target writes data to Amazon S3 based on the data format that you select.
- Avro
- The target writes records based on the Avro schema. You can use one of the following methods to specify the location of the Avro schema definition:
- Binary
- The stage writes binary data to a single field in the record.
- Delimited
- The target writes records as delimited data. When you use this data format, the root field must be list or list-map.
- JSON
- The target writes records as JSON data. You can use one of
the following formats:
- Array - Each file includes a single array. In the array, each element is a JSON representation of each record.
- Multiple objects - Each file includes multiple JSON objects. Each object is a JSON representation of a record.
- Parquet
- The target writes an object for each partition and includes the Parquet schema in every object.
- Protobuf
- Writes a batch of messages in each file.
- SDC Record
- The target writes records in the SDC Record data format.
- Text
- The target writes data from a single text field to the target system. When you configure the stage, you select the field to use.
- Whole File
- Streams whole files to the target system. The target writes the data to the file and location defined in the stage. If a file of the same name already exists, you can configure the target to overwrite the existing file or send the current file to error.