Load Data From S3 Bucket Using MuleSoft S3 Connector

If you would like to understand the basics of MuleSoft, refer to this article before going next:

Getting Started,

Setting up user access key and secret key

  1. Open https://console.aws.amazon.com/console/home
  2. Log in with your AWS Credentials, Create an AWS account if you don’t have one.
  3. Go to IAM (Manage access to AWS resources)

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  4. Go to Access management > Users > Add users.
  5. Provide Username > Attach policies directly > AmaxonS3FullAccess

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  6. Click Create user and go to the newly created user.
  7. Go to Security credentials and click Create access key.
  8. Copy the newly created access key and secret key.

    Load Data from S3 Bucket using MuleSoft S3 Connector

Prerequisite - Setting up Amazon S3

Step 1

Create your first S3 bucket.

Step 2

Upload an object to your bucket.

Load Data from S3 Bucket using MuleSoft S3 Connector

Step 3

Provide the project name and click Finish.

Load Data from S3 Bucket using MuleSoft S3 Connector

Step 3

CSV file data layout

Load Data from S3 Bucket using MuleSoft S3 Connector

Start MuleSoft

  1. Start Anypoint Studio and Create a new Mule Project from the File tab.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  2. Provide the project name and leave everything default and click Finish.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  3. Drag and drop Listener (HTTP) from Mule Palette to Message Flow.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  4. Go to Listener properties and set up Connection configuration and Path.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  5. Click the Add Connection configuration button, leave everything default, and click test connect.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  6. Enter Path value

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  7. Go to Mule Palette, click on Search in Exchange, search for S3, then select Amazon S3 Connector – Mule 4, hit Add button, and click Finish.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  8. Now drag and drop S3 Get Object from Mule Palette to the template.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  9. Go to Get Object properties and click the Add button in Connector configuration to add the connector.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  10. Enter required information like AWS access and secret keys, click test connection, and click OK.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  11. Enter other required information like Bucket name and Object key.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  12. Now drag and drop Transform Message from Mule Palette and out payload in application/json format.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  13. All looks good, now let’s deploy the application to see the output.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  14. Everything is running smoothly, with no errors, and the project deployed successfully. Now let’s open Postman to the data.

    Load Data from S3 Bucket using MuleSoft S3 Connector
     
  15. As you can see, Mule API provided the S3 bucket data in JSON form.

Conclusion

In this article, we learned how to connect the MuleSoft S3 connector and get data from the S3 bucket using the MuleSoft project.


Similar Articles