0

I am working with S3 clone, which, according to the documentation, has the same API as AWS S3. It's called Bluvalt: S3 REST API

Firstly, I created a working solution using Amazon S3 and it worked fine. However, when I have switched to S3-clone, the new provider is not detected with the new access key and secret. Here's the error I'm receiving:

An error has occurred, The AWS Access Key Id you provided does not exist in our records. (Service: Amazon S3; Status Code: 403; Error Code: InvalidAccessKeyId;

However, when I execute the file upload using AWS CLI it works fine. I have figured out that I have to add the endpoint to my Spring configuration.

I'm using spring-boot-starter-aws for connecting and operating.

Here are my properties:

cloud:
  aws:
    stack.auto: false
    region:
      static: ${S3_REGION}
    credentials.accessKey: ${S3_ACCESS_KEY}
    credentials.secretKey: ${S3_SECRET_KEY}

my-app:
  awsServices:
    bucketName: ${S3_BUCKET_NAME}

Is there a way to replace AWS endpoint with my provider?

Forin
  • 1,549
  • 2
  • 20
  • 44

2 Answers2

1

From a document of spring-cloud-aws. We have no way to set an s3 endpoint in a properties file.

As some useful topics:

Spring Cloud: testing S3 client with TestContainters

https://github.com/spring-cloud/spring-cloud-aws/issues/333

Tuan Vo
  • 1,875
  • 10
  • 10
0

I have figured it out. Below I post my working solution:

AmazonS3ClientBuilder
 .standard()
 .withClientConfiguration(configuration)
 .withEndpointConfiguration(new AwsClientBuilder
   .EndpointConfiguration(properties.getEndpointUrl(), properties.getRegion()))
 .withCredentials(credentialsProvider)
 .build();

Basically, you have to the following configuration to the client: .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(properties.getEndpointUrl(), properties.getRegion()))

Forin
  • 1,549
  • 2
  • 20
  • 44