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

Issues connecting to LocalStack #411

Open
JonathanWoollett-Light opened this issue Jan 12, 2025 · 0 comments
Open

Issues connecting to LocalStack #411

JonathanWoollett-Light opened this issue Jan 12, 2025 · 0 comments
Assignees
Labels

Comments

@JonathanWoollett-Light
Copy link

JonathanWoollett-Light commented Jan 12, 2025

Describe the bug

I'm running LocalStack for testing. To test this I am opening a connection and creating an S3 bucket.

I have some Python code which does this correctly:

import boto3

# Configure the S3 client to use LocalStack
s3_client = boto3.client(
    's3',
    endpoint_url='http://localhost:4566',
    aws_access_key_id='test',
    aws_secret_access_key='test',
    region_name='us-east-1'
)

# Create a bucket
bucket_name = "test-bucket"
try:
    s3_client.create_bucket(Bucket=bucket_name)
    print(f"Bucket '{bucket_name}' created successfully.")
except Exception as e:
    print(f"An error occurred: {str(e)}")

while my Rust code breaks:

#[tokio::main]
async fn main() {
    let region = s3::Region::Custom {
        region: String::from("us-east-1"),
        endpoint: String::from("http://127.0.0.1:4566"),
    };

    let credentials = awscreds::Credentials {
        access_key: Some(String::from("test")),
        secret_key: Some(String::from("test")),
        security_token: None,
        session_token: None,
        expiration: None,
    };
    let bucket = "test-bucket";
    let _create_bucket_response = s3::Bucket::create_with_path_style(
        bucket,
        region.clone(),
        credentials.clone(),
        s3::BucketConfiguration::public(),
    )
    .await
    .unwrap();
    let _handle = s3::Bucket::new(bucket, region, credentials).unwrap().with_path_style();
    
}

with:

thread 'main' panicked at src/main.rs:23:6:
called `Result::unwrap()` on an `Err` value: HttpFailWithBody(400, "<?xml version='1.0' encoding='utf-8'?>\n<Error><Code>InvalidLocationConstraint</Code><Message>The specified location-constraint is not valid</Message><RequestId>dce21a3a-661c-43b6-a11f-1ce14a185ce0</RequestId><LocationConstraint>us-east-1</LocationConstraint></Error>")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\testing.exe` (exit code: 101)

I've opened a PR to fix this #412 which removes it always setting the region in the config.

To Reproduce
Steps to reproduce the behavior (ideally with a minimal code sample):

  1. Install LocalStack.
  2. Run localstack start
  3. Download minimum viable example
  4. Run cargo test

Expected behavior

Bucket should be created (this can be verified with awslocal s3 ls).

Environment

  • Rust version: rustc 1.82.0 (f6e511eec 2024-10-15)
  • lib version: 0.35.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants