Write to an AWS S3 using MuleSoft within minutes!

MuleSoft is loaded with many connectors which makes life of a developer easy. Among many such connectors one important one is AWS S3 Connector. This makes connecting to S3 easy and efficient.

Here, I will show how to create a file in S3!


You will need an AWS account with S3 access. Best practice is to go to AWS IAM, create a user with programmatic access to S3. This keeps your AWS resources safe.

  • Here I have created an user aws-s3-poc and given AmazonS3FullAccess:
  • Now we will create a bucket in S3. I have created one called mule-tk. Also keep the region in mind because it will be used later in the app.

That is good enough for us to create an app and write or read to this bucket.

Steps to write to S3:

  • Create a Mule application in Anypoint Studio. I created one called aws-s3-poc
  • The AWS S3 will not be available in modules and so you need to add it from Exchange
  • Search for S3 as below. Select the S3 Connector and add it to the app

Another way is to add this dependency in the pom file:

  • Create a HTTP Listener listening to a port
  • Drag a Create Object from Amazon S3 connector
  • The flow should look like below:
  • Create a AWS S3 Connector Configuration by adding Access Key, Secret and use the same region as you used while creating S3. In my case its us-east-1
  • Now let's see what the Create Object configuration should look like:

The bucket name is the same name as you created before.

I am taking key and Object content from the user. So fileName attribute goes as key which is nothing but the name of the file as it will appear in s3 and Object content is the payload we want to save.

  • You can add another Transform Message to return a message to client

Finally run the application.

As you can see below, I sent a payload as :

    "fileName": "test.json",
    "message": {
        "name": "Tirthankar Kundu",
        "application": "MuleSoft"

Here fileName is test.json and message has my name and application in it. On sending we get back response as success

Now, Let us see what S3 bucket looks like:

So we see that a test.json file is created in the bucket.

On querying this file we see below response:

Thus, we were able to connect to write to Amazon S3 using MuleSoft within minutes.

Hope you liked it!

Tirthankar Kundu

Tirthankar Kundu