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
- Open https://console.aws.amazon.com/console/home
- Log in with your AWS Credentials, Create an AWS account if you don’t have one.
- Go to IAM (Manage access to AWS resources)
- Go to Access management > Users > Add users.
- Provide Username > Attach policies directly > AmaxonS3FullAccess
- Click Create user and go to the newly created user.
- Go to Security credentials and click Create access key.
- Copy the newly created access key and secret key.
Prerequisite - Setting up Amazon S3
Step 1
Create your first S3 bucket.
Step 2
Upload an object to your bucket.
Step 3
Provide the project name and click Finish.
Step 3
CSV file data layout
Start MuleSoft
- Start Anypoint Studio and Create a new Mule Project from the File tab.
- Provide the project name and leave everything default and click Finish.
- Drag and drop Listener (HTTP) from Mule Palette to Message Flow.
- Go to Listener properties and set up Connection configuration and Path.
- Click the Add Connection configuration button, leave everything default, and click test connect.
- Enter Path value
- 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.
- Now drag and drop S3 Get Object from Mule Palette to the template.
- Go to Get Object properties and click the Add button in Connector configuration to add the connector.
- Enter required information like AWS access and secret keys, click test connection, and click OK.
- Enter other required information like Bucket name and Object key.
- Now drag and drop Transform Message from Mule Palette and out payload in application/json format.
- All looks good, now let’s deploy the application to see the output.
- Everything is running smoothly, with no errors, and the project deployed successfully. Now let’s open Postman to the data.
- 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.