1

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 ?

2
  • Where is the s3 client application running? On your host or in a different container? Commented Jul 8, 2024 at 16:51
  • the application is running on host machine Commented Jul 9, 2024 at 6:18

2 Answers 2

1

Try to configure the Amazon S3 connection in your Quarkus application, especially when using a local endpoint (like localstack) something like this:

  1. Add this in your application.properties file:
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
  1. Ensure you have the correct dependency in your pom.xml:
<dependency>
  <groupId>io.quarkiverse.amazonservices</groupId>
  <artifactId>quarkus-amazon-s3</artifactId>
</dependency>

Here's the documentation s3 quarkus

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.