ListS3 2.0.0

Bundle
org.apache.nifi | nifi-aws-nar
Description
Retrieves a listing of objects from an S3 bucket. For each object that is listed, creates a FlowFile that represents the object so that it can be fetched in conjunction with FetchS3Object. This Processor is designed to run on Primary Node only in a cluster. If the primary node changes, the new Primary Node will pick up where the previous node left off without duplicating all of the data.
Tags
AWS, Amazon, S3, list
Input Requirement
FORBIDDEN
Supports Sensitive Dynamic Properties
false
  • Additional Details for ListS3 2.0.0

    ListS3

    Streaming Versus Batch Processing

    ListS3 performs a listing of all S3 Objects that it encounters in the configured S3 bucket. There are two common, broadly defined use cases.

    Streaming Use Case

    By default, the Processor will create a separate FlowFile for each object in the bucket and add attributes for filename, bucket, etc. A common use case is to connect ListS3 to the FetchS3 processor. These two processors used in conjunction with one another provide the ability to easily monitor a bucket and fetch the contents of any new object as it lands in S3 in an efficient streaming fashion.

    Batch Use Case

    Another common use case is the desire to process all newly arriving objects in a given bucket, and to then perform some action only when all objects have completed their processing. The above approach of streaming the data makes this difficult, because NiFi is inherently a streaming platform in that there is no “job” that has a beginning and an end. Data is simply picked up as it becomes available.

    To solve this, the ListS3 Processor can optionally be configured with a Record Writer. When a Record Writer is configured, a single FlowFile will be created that will contain a Record for each object in the bucket, instead of a separate FlowFile per object. See the documentation for ListFile for an example of how to build a dataflow that allows for processing all the objects before proceeding with any other step.

    One important difference between the data produced by ListFile and ListS3, though, is the structure of the Records that are emitted. The Records emitted by ListFile have a different schema than those emitted by ListS3. ListS3 emits records that follow the following schema (in Avro format):

    {
      "type": "record",
      "name": "nifiRecord",
      "namespace": "org.apache.nifi",
      "fields": [
        {
          "name": "key",
          "type": "string"
        },
        {
          "name": "bucket",
          "type": "string"
        },
        {
          "name": "owner",
          "type": [
            "null",
            "string"
          ]
        },
        {
          "name": "etag",
          "type": "string"
        },
        {
          "name": "lastModified",
          "type": {
            "type": "long",
            "logicalType": "timestamp-millis"
          }
        },
        {
          "name": "size",
          "type": "long"
        },
        {
          "name": "storageClass",
          "type": "string"
        },
        {
          "name": "latest",
          "type": "boolean"
        },
        {
          "name": "versionId",
          "type": [
            "null",
            "string"
          ]
        },
        {
          "name": "tags",
          "type": [
            "null",
            {
              "type": "map",
              "values": "string"
            }
          ]
        },
        {
          "name": "userMetadata",
          "type": [
            "null",
            {
              "type": "map",
              "values": "string"
            }
          ]
        }
      ]
    }
    
Properties
State Management
Scopes Description
CLUSTER After performing a listing of keys, the timestamp of the newest key is stored, along with the keys that share that same timestamp. This allows the Processor to list only keys that have been added or modified after this date the next time that the Processor is run. State is stored across the cluster so that this Processor can be run on Primary Node only and if a new Primary Node is selected, the new node can pick up where the previous node left off, without duplicating the data.
Relationships
Name Description
success FlowFiles are routed to this Relationship after they have been successfully processed.
Writes Attributes
Name Description
s3.bucket The name of the S3 bucket
s3.region The region of the S3 bucket
filename The name of the file
s3.etag The ETag that can be used to see if the file has changed
s3.isLatest A boolean indicating if this is the latest version of the object
s3.lastModified The last modified time in milliseconds since epoch in UTC time
s3.length The size of the object in bytes
s3.storeClass The storage class of the object
s3.version The version of the object, if applicable
s3.tag.___ If 'Write Object Tags' is set to 'True', the tags associated to the S3 object that is being listed will be written as part of the flowfile attributes
s3.user.metadata.___ If 'Write User Metadata' is set to 'True', the user defined metadata associated to the S3 object that is being listed will be written as part of the flowfile attributes
See Also