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
To access Amazon Simple Storage Service, create an AWS. S3 service object. Call the listBuckets method of the Amazon S3 service object to retrieve a list of your buckets. The data parameter of the callback function has a Buckets property containing an array of maps to represent the buckets.
Develop and deploy applications with the AWS SDK for Java. The SDK makes it easy to call AWS services using idiomatic Java APIs.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With