I am building a spring boot application that can upload images to an s3 bucket. When its finished it will run on an EC2 instance that is in the same region as my s3 buckets.
The sping boot application is using the AWS sdk for java to connect to and upload files to s3. The s3Client class that does the uploading is instantiated in the following way:
@Bean
public AmazonS3 s3client() {
BasicAWSCredentials awsCreds = new BasicAWSCredentials(awsId, awsKey);
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withRegion(Regions.fromName(region))
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withClientConfiguration(
new ClientConfiguration()
.withMaxConnections(MAX_CONNECTIONS)
.withMaxErrorRetry(3)
)
.build();
return s3Client;
}
When I upload a file from localhost it must go through the public internet. But i want the s3Client to use the internal network of the AWS region once the application is running on EC2, simply because its a lot faster.
My question is: Will the s3Client do this by default or do i need to configure it to use the internal network? If so, how do i do that?
Thanks