Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. This means customers of all sizes and industries can use it to store and protect any amount of data for a range of use cases, such as data lakes, websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics.
The Ballerina AWS S3 provides the capability to manage buckets and objects in AWS S3.
This module supports Amazon S3 REST API 2006-03-01 version.
| Version | |
|---|---|
| Ballerina Language | Swan Lake 2201.12.0 |
| Amazon S3 API | 2006-03-01 |
Before using this connector in your Ballerina application, complete the following:
- Create an AWS account
- Obtain tokens
To use the AWS S3 connector in your Ballerina application, update the .bal file as follows:
Import the ballerinax/aws.s3 module into the Ballerina project.
import ballerinax/aws.s3;Create a s3:ConnectionConfig with the tokens obtained, and initialize the connector with it.
s3:ConnectionConfig amazonS3Config = {
accessKeyId: <ACCESS_KEY_ID>,
secretAccessKey: <SECRET_ACCESS_KEY>,
region: <REGION>
};
s3:Client amazonS3Client = check new(amazonS3Config);-
Now you can use the operations available within the connector. Note that they are in the form of remote operations. Following is an example on how to create a bucket using the connector.
string bucketName = "name"; public function main() returns error? { _ = check amazonS3Client->createBucket(bucketName); }
-
Use
bal runcommand to compile and run the Ballerina program.
You can find a list of samples here
-
Download and install Java SE Development Kit (JDK) version 11. You can install either OpenJDK or Oracle JDK.
Note: Set the JAVA_HOME environment variable to the path name of the directory into which you installed JDK.
-
Download and install Ballerina Swan Lake
Execute the commands below to build from the source:
- To build the package:
bal build ./ballerina - To run the tests after build:
bal test ./ballerina
As an open source project, Ballerina welcomes contributions from the community.
For more information, see contribution guidelines.
All contributors are encouraged to read the Ballerina Code of Conduct.
- Discuss code changes of the Ballerina project via ballerina-dev@googlegroups.com.
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.