Chapter 16. AWS S3 Source


Receive data from an Amazon S3 Bucket.

The basic authentication method for the S3 service is to specify an access key and a secret key. These parameters are optional because the Kamelet provides a default credentials provider.

If you use the default credentials provider, the S3 client loads the credentials through this provider and doesn’t use the basic authentication method.

Two headers are duplicated with different names for clarity at sink level. CamelAwsS3Key is duplicated into aws.s3.key and CamelAwsS3BucketName is duplicated in aws.s3.bucket.name.

16.1. Authentication methods

In this Kamelet you can avoid using explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.

The order of evaluation for Default Credentials Provider is the following:

  • Java system properties - aws.accessKeyId and aws.secretKey.
  • Environment variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  • Web Identity Token from AWS STS.
  • The shared credentials and config files.
  • Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set.
  • Amazon EC2 Instance profile credentials.

You can also use the Profile Credentials Provider, by setting the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.

Only one of access key/secret key or default credentials provider could be used

For more information, see the AWS credentials documentation

16.2. Usage examples

You could consume the bucket content and directly delete the object once consumed

- route:
    from:
      uri: "kamelet:aws-s3-source"
      parameters:
        useDefaultCredentialsProvider: true
        region: "eu-west-1"
        bucketNameOrArn: "kamelets"
      steps:
        - to:
            uri: "kamelet:log-sink"

This kind of approach ensures that the object is consumed just one time and after the consumption it is deleted from the S3 bucket.

The deleteAfterRead property is true by default.

If you set the property to false you’ll consume the same set of objects multiple times and you’ll have to deal with managing the situation.

The ignoreBody option is set to false by default, but you can enable it. With that option set you’re going to ignore the file payload and just consume the object metadata.

You could also define a prefix parameter. With that set you’re going to consume only files starting with that prefix. As an example you could have:

- route:
    from:
      uri: "kamelet:aws-s3-source"
      parameters:
        useDefaultCredentialsProvider: true
        region: "eu-west-1"
        bucketNameOrArn: "kamelets"
        prefix: "foo/"
      steps:
        - to:
            uri: "kamelet:log-sink"

By using the prefix foo/ the files consumed will only come from the folder named foo.

16.3. Configuration Options

The following table summarizes the configuration options available for the aws-s3-source Kamelet:

Expand
PropertyNameDescriptionTypeDefaultExample

bucketNameOrArn *

Bucket Name

The S3 Bucket name or Amazon Resource Name (ARN).

string

  

region *

AWS Region

The AWS region to access.

string

  

accessKey

Access Key

The access key obtained from AWS.

string

  

autoCreateBucket

Autocreate Bucket

Specifies to automatically create the S3 bucket.

boolean

False

 

delay

Delay

The number of milliseconds before the next poll of the selected bucket.

integer

500

 

deleteAfterRead

Auto-delete Objects

Specifies to delete objects after consuming them.

boolean

True

 

destinationBucket

Destination Bucket

Define the destination bucket where an object must be moved when moveAfterRead is set to true.

string

  

destinationBucketPrefix

Destination Bucket Prefix

Define the destination bucket prefix to use when an object must be moved, and moveAfterRead is set to true.

string

  

destinationBucketSuffix

Destination Bucket Suffix

Define the destination bucket suffix to use when an object must be moved, and moveAfterRead is set to true.

string

  

forcePathStyle

Force Path Style

Forces path style when accessing AWS S3 buckets.

boolean

False

 

ignoreBody

Ignore Body

If true, the S3 Object body is ignored. Setting this to true overrides any behavior defined by the includeBody option. If false, the S3 object is put in the body.

boolean

False

 

maxMessagesPerPoll

Max Messages Per Poll

Gets the maximum number of messages as a limit to poll at each polling. Gets the maximum number of messages as a limit to poll at each polling. The default value is 10. Use 0 or a negative number to set it as unlimited.

integer

10

 

moveAfterRead

Move Objects After Delete

Move objects from S3 bucket to a different bucket after they have been retrieved.

boolean

False

 

overrideEndpoint

Endpoint Overwrite

Select this option to override the endpoint URI. To use this option, you must also provide a URI for the uriEndpointOverride option.

boolean

False

 

prefix

Prefix

The AWS S3 bucket prefix to consider while searching.

string

 

folder/

profileCredentialsName

Profile Credentials Name

If using a profile credentials provider this parameter sets the profile name.

string

  

secretKey

Secret Key

The secret key obtained from AWS.

string

  

sessionToken

Session Token

Amazon AWS Session Token used when the user needs to assume a IAM role.

string

  

uriEndpointOverride

Overwrite Endpoint URI

The overriding endpoint URI. To use this option, you must also select the overrideEndpoint option.

string

  

useDefaultCredentialsProvider

Default Credentials Provider

If true, the S3 client loads credentials through a default credentials provider. If false, it uses the basic authentication method (access key and secret key).

boolean

False

 

useProfileCredentialsProvider

Profile Credentials Provider

Set whether the S3 client should expect to load credentials through a profile credentials provider.

boolean

False

 

useSessionCredentials

Session Credentials

Set whether the S3 client should expect to use Session Credentials. This is useful in situation in which the user needs to assume a IAM role for doing operations in S3.

boolean

False

 

* = Fields marked with an asterisk are mandatory.

16.4. Dependencies

16.4.1. Quarkus dependencies

<dependencies>
  <dependency>
    <groupId>org.apache.camel.kamelets</groupId>
    <artifactId>camel-kamelets-utils</artifactId>
    <version>4.8.5</version>
  </dependency>
  <dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-aws-s3-source</artifactId>
  </dependency>
  <dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-aws2-s3</artifactId>
  </dependency>
  <dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-kamelet</artifactId>
  </dependency>
</dependencies>

16.5. Usage

16.5.1. Camel JBang usage

16.5.1.1. Prerequisites for JBang

  • Install JBang.
  • You have executed the following command:

    jbang app install camel@apache/camel

16.5.1.2. Running a route with JBang

Suppose you have a file named route.yaml with this content:

- route:
    from:
      uri: "kamelet:timer-source"
      parameters:
        period: 10000
        message: 'test'
      steps:
        - to:
            uri: "kamelet:log-sink"

You can now run it directly through the following command.

camel run route.yaml

16.5.2. Knative Source

You can use the aws-s3-source Kamelet as a Knative source by binding it to a Knative object.

aws-s3-source-binding.yaml

apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
  name: aws-s3-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1
      name: aws-s3-source
    properties:
      accessKey: "The Access Key"
      bucketNameOrArn: "The Bucket Name"
      region: "eu-west-1"
      secretKey: "The Secret Key"
  sink:
    ref:
      kind: Channel
      apiVersion: messaging.knative.dev/v1
      name: mychannel

16.5.3. Kafka Source

You can use the aws-s3-source Kamelet as a Kafka source by binding it to a Kafka topic.

aws-s3-source-binding.yaml

apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
  name: aws-s3-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1
      name: aws-s3-source
    properties:
      accessKey: "The Access Key"
      bucketNameOrArn: "The Bucket Name"
      region: "eu-west-1"
      secretKey: "The Secret Key"
  sink:
    ref:
      kind: KafkaTopic
      apiVersion: kafka.strimzi.io/v1beta1
      name: my-topic

16.6. Kamelets source file

https://github.com/jboss-fuse/camel-kamelets/blob/camel-kamelets-4.10.3-branch/kamelets/aws-s3-source.kamelet.yaml

Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top