Reputation: 329
I have quarkus application with an REST endpoint to upload file to S3.
With devservices by default I can see localstack container running.
I am trying to build s3client as below and the application launches fine.
public S3AsyncClient getS3Client() {
AwsBasicCredentials credentials = AwsBasicCredentials.create("test-key", "test-secret");
return S3AsyncClient.builder().credentialsProvider(StaticCredentialsProvider.create(credentials))
.endpointOverride(URI.create("http://localhost:4566"))
.region(Region.AP_SOUTH_1)
.build();
}
When the request is sent getting UnKnownHost exception.
"Received an UnknownHostException when attempting to interact with a service. See cause for the exact endpoint that is failing to resolve. If this is happening on an endpoint that previously worked, there may be a network connectivity issue or your DNS cache could be storing endpoints for too long."
Container View
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8a060b1ef175 localstack/localstack:3.0.1 "docker-entrypoint.sh" 3 minutes ago Up 3 minutes (healthy) 4510-4559/tcp, 5678/tcp, 0.0.0.0:50263->4566/tcp epic_chandrasekhar
d8fee11b5eee testcontainers/ryuk:0.6.0 "/bin/ryuk" 3 minutes ago Up 3 minutes 0.0.0.0:50261->8080/tcp testcontainers-ryuk-40638bfc-187f-4540-a786-ab1bc49e63b9
Why is it throwing unknownhost exception ?
Upvotes: 1
Views: 369
Reputation: 4449
This began happening with version 2.18 of the S3 library, when the bucket value formatting changed. Version 2.17 didn't have this error. Set .forcePathStyle(true)
on the S3AsyncClientBuilder to revert to the 2.17 behavior
https://github.com/aws/aws-sdk-java-v2/issues/3524
Upvotes: 1
Reputation: 11
Try to configure the Amazon S3 connection in your Quarkus application, especially when using a local endpoint (like localstack) something like this:
quarkus.s3.sync-client.type=apache
quarkus.s3.aws.region=us-east-1
quarkus.s3.aws.credentials.type=default
quarkus.s3.path-style-access=false
%dev.quarkus.s3.endpoint-override=http://localhost:4566
%dev.quarkus.s3.path-style-access=true
%dev.quarkus.s3.aws.credentials.type=static
%dev.quarkus.s3.aws.credentials.static-provider.access-key-id=test-key
%dev.quarkus.s3.aws.credentials.static-provider.secret-access-key=test-secret
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-s3</artifactId>
</dependency>
Here's the documentation s3 quarkus
Upvotes: 1