9

So i am able to configure a local s3 bucket using localstack with the following command

aws --endpoint-url=http://localhost:4572 s3 mb s3://mytestbucket

How am I able to change the configuration for the java AWS SDK in order to write/read from/to this bucket instead of remote aws s3?

I have looked at the configuration but not able to find any tangible

L-Samuels
  • 2,712
  • 9
  • 34
  • 42

2 Answers2

12

This is done via the endpoint configuration within the AWS S3 SDK when creating the client. For example:

final AwsClientBuilder.EndpointConfiguration endpoint = new AwsClientBuilder.EndpointConfiguration(s3Endpoint, REGION);
        final AmazonS3 client = AmazonS3ClientBuilder.standard()
            .withEndpointConfiguration(endpoint)
            .build();

The endpoint can be a string like http://localhost:4572 (where the port number needs to be whatever port s3 in localstack is listening on - by default 4572)

David
  • 7,652
  • 21
  • 60
  • 98
5

Now the s3 endpoint is updated in localstack .

Please use the below url : http://s3.localhost.localstack.cloud:4566

Suman Mandal
  • 51
  • 1
  • 1
  • Thanks for the answer, the above url is working actually and i can't find this mentioned anywhere in documentation. can you please update the answer with the documentation reference. so that will refer all the services not only s3. –  Feb 13 '23 at 12:36