Connecting CBCloudDrive to Amazon S3


Requirements: CBFSCloud

This article explains how to configure CBCloudDrive to connect to Amazon S3. For a general overview of how the component works, see Getting Started with the CBCloudDrive Component.

Getting Started

First go ahead and set the ConnectionType property to ctS3 and set CacheDirectory to a valid, writable local directory path. After that, you can build a connection string using the below parameters.

Connection Parameters

Parameter Description
RemoteRoot The S3-style path to use as the root of the mounted drive. The first path segment must be the bucket name (e.g., /my-bucket). Additional segments are treated as object key prefixes (e.g., /my-bucket/folder/subfolder).
AccessKey The access key for authentication. Not required when using anonymous, profile, or EC2 role authentication.
SecretKey The secret key for authentication. Not required when using anonymous, profile, or EC2 role authentication.

Authentication

To connect to Amazon S3 using standard access keys, set the AccessKey and SecretKey connection parameters in the connection string as shown below.

drive.ConnectionType = CBCloudDriveConnectionTypes.ctS3; drive.ConnectionString = "RemoteRoot=/my-bucket;AccessKey=MYACCESSKEY;SecretKey=MYSECRETKEY;";

AWS Credentials Profile

To load credentials from an AWS credentials file instead of specifying them directly, set UseAWSProfile to true. By default, the component reads from the default profile at the standard credentials file location (~/.aws/)

Use AWSProfile to specify a different profile name, and AWSProfileDir to specify a different directory.

drive.ConnectionString = "RemoteRoot=/my-bucket;UseAWSProfile=true;AWSProfile=my-profile;";

EC2 Role Credentials

When running on an EC2 instance, the component can retrieve temporary credentials automatically from the instance metadata service (IMDS). Set UseEC2RoleCredentials to true; no access key or secret key is needed. IMDSv2 is used by default.

drive.ConnectionString = "RemoteRoot=/my-bucket;UseEC2RoleCredentials=true;";

Anonymous

To access publicly readable buckets without credentials, set UseAnonymousAuthentication to true.

drive.ConnectionString = "RemoteRoot=/my-public-bucket;UseAnonymousAuthentication=true;";

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@callback.com.