Skip to content

bug: aws java sdk v1 seems to not be able to retrieve region from localstack S3 bucket #12585

Closed
@bnbourgade

Description

@bnbourgade

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Hello,

I'm writing this issue to ask you about about a problem i encounter when using localstack bucket.
I have a scala script i want to use on AWS later, and I need to read a file from a S3 bucket. In my local local version i'm using a localstack container.

However, when running my code, I get an error telling me that the bucket does not exist.

Any ideas about whay I could have done wrong with localstack for that to happen ?

Expected Behavior

I expect the listBuckets method of AmazonS3 to return a Bucket of region that is not null

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

# How I create the localstack elems:

I run a container from image localstack/localstack:latest, with the following env variables :

AWS_DEFAULT_REGION: eu-west-1
AWS_ACCESS_KEY_ID: admin
AWS_SECRET_ACCESS_KEY: password

Then, once the container is running, i create a bucket with the following command :
awslocal s3 mb s3://my-bucket --region eu-west-1

How I (try to) access my bucket

In my scala script, I create a AmazonS3 client the following way :

private val s3: AmazonS3 = AmazonS3ClientBuilder
    .standard()
    .withEndpointConfiguration(
      new EndpointConfiguration(endpoint, region)
    )
    .withCredentials(
      new AWSStaticCredentialsProvider(
        new BasicAWSCredentials(accessKeyId, secretAccessKey)
      )
    )
    .build()

// endpoint is "http://localhost:4566"
// region is "eu-west-1"
// accessKeyId is "admin"
// secretAccessKey is "password"

Then, when run s3.listBuckets() i have the following line :
[S3Bucket [name=my-bucket, creationDate=Tue May 06 11:22:21 CEST 2025, owner=S3Owner [name=webfile,id=75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a], region=null]]

Moreover, running s3.getObject("my-bucket","/path/to/file") tells me that NoSuchBucket

Environment

# Versions

aws-java-sdk-s3 : 1.12.782 (can't upgrade to sdkv2 because bounded by scala version)
localstack image : latest
awslocal cli : latest, installed yesterday (May 5th 2025)

Anything else?

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions