S3 access always prefixes bucket name before "localhost"

Hi folks, writing a test case using localstack with an s3 bucket. Created the bucket in test following this link, however, when I try to access the bucket, for some reason the bucket name is always prefixed before localhost, so the URL that I am trying to upload to becomes http://bucket.localhost:4566/000000000000/qaqc-report/20220729.avro , result in failure.What is interesting is that, my code works in DEV after deployment, so perhaps there are some localstack issue? Would appreciate some insight I can access the bucket using aws CLI just fine

aws --endpoint-url=http://localhost:4566 s3 ls
2022-07-28 20:14:16 bucket

Hi @howardxie , thanks for reporting. This is related to how the AWS S3 SDK is constructing the endpoint URLs to interact with the API.

There are basically 2 options:

  • Configure your AWS S3 SDK to use path based addressing (as opposed to hostname based addressing)
  • Configure your AWS S3 SDK to use http://s3.localhost.localstack.cloud:4566 as the endpoint URL

Hope that helps - please keep us posted on how it goes… Thanks!

1 Like