Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom s3 endpoint url for 'plugin-node' #2176

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dtbuchholz
Copy link

@dtbuchholz dtbuchholz commented Jan 12, 2025

Relates to

#2174

Risks

Low. This affects only the plugin-node, and it changes logic in a way that is backward compatible.

Background

What does this PR do?

This changes the plugin-node to, optionally, use a custom AWS_S3_ENDPOINT. If this value is not set, the existing behavior is used, which explicitly calls the official AWS S3 URL. If the value is set (e.g., http://localhost:8014), it instead uses this custom URL when reading/writing data. Closes #2174.

What kind of change is this?

Feature; improves the S3 plugin functionality.

Why are we doing this? Any context or related work?

Eliza should make it so that AWS isn't the only S3 provider. Right now, it's an enshrined plugin. If we merge this PR, anyone that builds an S3-compatible tool can use the plugin; it becomes more flexible.

For reference, I'm building a web3 native object storage layer, which has S3 compatability—called Basin: https://basin.textile.io. We have an S3 adapter that works with MinIO, boto3, etc. I tested this plugin against our adapter, and everything worked as expected (more on this below).

Documentation changes needed?

  • Updated the plugin-node README to mention this variable
  • Added to the .env.example file

Testing

Where should a reviewer start?

If you'd like to test this flow, you'll need to use some local S3 compatible server. A popular one is MinIO. Once you have the server running, it should log the local port. You can then set the .env variable AWS_S3_ENDPOINT to this value (e.g., http://localhost:8014), and then call uploadFile.

Detailed testing steps

I tested this against our S3 adapter with both raw and resigned URLs. For example:

const s3 = runtime?.getService(ServiceType.AWS_S3) as IAwsS3Service;
const tempFile = path.join(os.tmpdir(), "test.txt");
writeFileSync(tempFile, "test content");
const fileContent = readFileSync(tempFile, "utf8");
elizaLogger.log("File content:", fileContent);
const { success, url, error } = await s3.uploadFile(
    tempFile,
    "",
    true,
    3600
);
console.log(url);
// Default `url` value: `http://localhost:8014/eliza/images/1736652765063-test.txt`
// If presigned: `http://localhost:8014/eliza/images/1736652765063-test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKEXAMPLES3S%2F20250112%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250112T033246Z&X-Amz-Expires=3600&X-Amz-Signature=ebd5aaaf39c272ff22017289327851512597cdc5e9549156cd1adee3426135de&X-Amz-SignedHeaders=host&x-id=GetObject`

If AWS_S3_ENDPOINT is not set, then it uses the normal S3 format.

Discord username

dtb_

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dtbuchholz! Welcome to the ai16z community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now a ai16z contributor!

@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 8f686e2 to 38f1a77 Compare January 12, 2025 04:08
@dtbuchholz dtbuchholz changed the base branch from main to develop January 12, 2025 04:08
@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 38f1a77 to 59068c4 Compare January 12, 2025 04:09
odilitime
odilitime previously approved these changes Jan 12, 2025
@odilitime odilitime enabled auto-merge January 12, 2025 09:15
auto-merge was automatically disabled January 13, 2025 18:41

Head branch was pushed to by a user without write access

@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 59068c4 to 0f0e3f4 Compare January 13, 2025 18:41
@dtbuchholz
Copy link
Author

@odilitime thanks for the quick review! i just rebased on the latest from develop (to resolve a pnpm lockfile mismatch) and force pushed the changes.

is there anything else I need to do on my end to get things merged? (I'm new to the repo and am just curious what the process looks like.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for custom S3 endpoints in plugin-node
2 participants