Using AWS SDK S3 with MinIO

I've been trying to setup the aws-sdk-s3 library to talk to a local MinIO S3 instance, but I keep hitting a deadend wheneven I call any method other than list_buckets. The error I get is the following:

panicked at 'called `Result::unwrap()` on an `Err` value: ServiceError(ServiceError { source: Unhandled(Unhandled { source: ErrorMetadata { code: Some("SignatureDoesNotMatch"), message: Some("The request signature we calculated does not match the signature you provided. Check your key and signing method.")

Things that I have tried, include:

  1. Setting the endpoint configuration directly in the aws config (a.k.a. just following the examples provided in the library's repository):
let region_provider = RegionProviderChain::first_try(Region::new("us-west-2"));
let shared_config = aws_config::from_env().credentials_provider(Credentials::new("development", "development", None, None, "s3")).endpoint_url("http://localhost:9000").region(region_provider).load().await;
  1. Change MinIO's port to 80, since there are several search results pointing to a known bug in AWS SDKs where the SDK does not consider the port for the signature.

  2. Use a config builder so that I can pass the force_path_style flag:

let client_config = Builder::new()
  .credentials_provider(Credentials::new("development", "development", None, None, "example"))

I must be missing something, but can't figure out what that could be, hence why I'm asking to check if someone from the community has a similar, working development environment.

Note: Everything works with the rust-s3 library, so it's definitely something with the official AWS SDK configuration.

Had the same problem today, updated to latest crates &using docker minio image

This works for me, hope that helps:

        let key_id = dotenv_codegen::dotenv!("MINIO_ACCESS_KEY_ID").to_string();
        let secret_key = dotenv_codegen::dotenv!("MINIO_SECRET_ACCESS_KEY").to_string();

        let cred = Credentials::new(key_id, secret_key, None, None, "loaded-from-custom-env");

        let url = dotenv_codegen::dotenv!("MINIO_URL");
        let s3_config = aws_sdk_s3::config::Builder::new()
            .force_path_style(true) // apply bucketname as path param instead of pre-domain

        let client = aws_sdk_s3::Client::from_conf(s3_config);

1 Like

Thanks for your reply, @chikko80. Your configuration is exactly like mine, so it pointed me into the right direction: It wasn't actually the config what was wrong, but the syntax that I was using to name the bucket. In rust-s3 you prefix the bucket names with a forward slash (/my-bucket), but the AWS SDK client doesn't expect such prefix :man_shrugging:.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.