Skip to content

ballerina-platform/module-ballerinax-aws.s3

Repository files navigation

Ballerina Amazon S3 Connector

Build Status codecov GitHub Last Commit GraalVM Check License

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.

Overview

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.

Compatibility

Version
Ballerina Language Swan Lake 2201.12.0
Amazon S3 API 2006-03-01

Prerequisites

Before using this connector in your Ballerina application, complete the following:

  1. Create an AWS account
  2. Obtain tokens

Quickstart

To use the AWS S3 connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

Import the ballerinax/aws.s3 module into the Ballerina project.

import ballerinax/aws.s3;

Step 2: Create a new connector instance

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);

Step 3: Invoke connector operation

  1. 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);
    }
  2. Use bal run command to compile and run the Ballerina program.

You can find a list of samples here

Building from the source

Setting up the prerequisites

  1. 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.

  2. Download and install Ballerina Swan Lake

Building the source

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
    

Contributing to Ballerina

As an open source project, Ballerina welcomes contributions from the community.

For more information, see contribution guidelines.

Code of conduct

All contributors are encouraged to read the Ballerina Code of Conduct.

Useful links

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 49