-1

I am having a spring boot app and it's deployed over the AWS EKS cluster. There is one maven dependency 'aws-java-sdk' . Earlier it was running fine with the older version - 1.11.52, but when I have updated the version to - 1.12.470. It start giving me 504 Gateway Time-out error.

 <dependency>
   <groupId>com.amazonaws</groupId>
   <artifactId>aws-java-sdk</artifactId>
   <version>1.12.470</version>
 </dependency>

Also check with cloudwatch related to HTTP Errors, no errors are coming.

Mohit Sharma
  • 167
  • 7

3 Answers3

1

You are using AWS SDK for Java V1 - which is not best practice. You should strongly consider moving to AWS SDK for Java V2. The POM dependency is:

 <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>bom</artifactId>
        <version>2.20.45</version>
        <type>pom</type>
        <scope>import</scope>
 </dependency>

Here is the DEV Guide:

Developer Guide - AWS SDK for Java 2.x

The AWS SDK for Java 2.x is a major rewrite of the version 1.x code base. It’s built on top of Java 8+ and adds several frequently requested features. These include support for non-blocking I/O and the ability to plug in a different HTTP implementation at runtime.

The AWS SDK for Java V2 works great with Spring Boot. Refer to this example:

Build an application to submit data to a DynamoDB table

smac2020
  • 9,637
  • 4
  • 24
  • 38
0

Usually security/firewall related issue somewhere...

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-504-gateway-timeout.html

An HTTP 504 status code (Gateway Timeout) indicates that when CloudFront forwarded a request to the origin (because the requested object wasn't in the edge cache), one of the following happened:

The origin returned an HTTP 504 status code to CloudFront.

The origin didn't respond before the request expired.

CloudFront will return an HTTP 504 status code if traffic is blocked to the origin by a firewall or security group, or if the origin isn't accessible on the internet. Check for those issues first. Then, if access isn't the problem, explore application delays and server timeouts to help you identify and fix the issues.

CharithJ
  • 46,289
  • 20
  • 116
  • 131
0

I was able to solve it by adding only the dependency I need-

  <dependency>
     <groupId>com.amazonaws</groupId>
     <artifactId>aws-java-sdk-sts</artifactId>
     <version>1.12.472</version>
  </dependency>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-rds</artifactId>
    <version>1.12.472</version>
  </dependency>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-cognitoidp</artifactId>
    <version>1.12.472</version>
  </dependency>

The problem with aws-sdk-java is that it download the complete jars package which are the part of aws sdk ecosystem and the others jars may conflict with the EKS causing the issues. One more thing that all the aws-sdk jars version should be exact same, since internally they have dependency on other aws jars as well which also might create problems.

It was advisable to use the relevant jars that you needed, not the complete package.

Mohit Sharma
  • 167
  • 7