I have this situation where I am able to connect to the AWS S3 bucket without actually mentioning the path to the s3 bucket. I am only passing the client, secret, region & bucket name and able to connect to the AWS S3 bucket. I have this only application (SBApp) code repository where I can’t make changes to connect to the S3 bucket. ( What change? explained ahead.)
The following code in the SBApp is responsible for connecting to the AWS S3 bucket without using AWS S3 url :
AmazonS3 s3client = s3client = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(getCredentials()))
.withRegion(amazonS3ResourceConfig.getS3RuleRegion())
.build();
I am writing a docker-containerized application (QEApp) where I will be using the above application(SBApp) jar which will run in the docker container. And to use S3 bucket, I’m using localstack.
And the following code is responsible for connecting the localstack S3 bucket using localstack-host url:
AmazonS3 s3client = AmazonS3ClientBuilder.standard()
.withCredentials(
new AWSStaticCredentialsProvider(
new BasicAWSCredentials(
amazonS3ResourceConfig.getClientId(), amazonS3ResourceConfig.getClientPassword())))
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(amazonS3ResourceConfig.getAwsS3Url(), amazonS3ResourceConfig.getS3RuleRegion()))
.withPathStyleAccessEnabled(true)
.build();
Problem
The problem is that, I need localstack-host url to connect to the localstack s3 bucket but my applicaiton(SBApp) repository doesn’t allow me to make changes to the code that establishes connection with the AWS S3 bucket.
So, I need a way to connect to the localstack s3 bucket without using the localstack-host url.
Kindly suggest a way to solve this problem.