Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AmazonS3ClientBuilder assumed the Node role instead of ServiceAccount role #3648

Closed
harmeet-singh-discovery opened this issue Jun 9, 2023 · 0 comments · Fixed by #3696
Closed

Comments

@harmeet-singh-discovery
Copy link
Contributor

Expected Behavior

When Java server runs on AWS EKS pod, I get the following error:
Caused by: com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;

After debugging, I found that the S3Client that interacts with S3 assumed the Node role, instead of the ServiceAccount Role.

Current Behavior

The S3Client that interacts with S3 assumed the Node role, instead of the ServiceAccount Role.

Steps to reproduce

Specifications

  • Version:
  • Platform:
  • Subsystem:

Possible Solution

I made the following change and deployed the java service on AWS EKS. I was able to run the server without encountering above mentioned error.

@Provides
 public AmazonS3 awsStorage(ApplicationProperties applicationProperties) {
     AmazonS3ClientBuilder builder=AmazonS3ClientBuilder.standard().withRegion(applicationProperties.getFeast().getAwsRegion());  
    String roleArn = applicationProperties.getFeast().getRoleRegion();
    String webIdentityTokenFile = applicationProperties.getFeast().getToken();

    if (roleArn != null && webIdentityTokenFile != null) {
        WebIdentityTokenCredentialsProvider credentialsProvider = WebIdentityTokenCredentialsProvider.builder()
                .roleArn(roleArn)
                .webIdentityTokenFile(webIdentityTokenFile)
                .build();

        builder.withCredentials(credentialsProvider);
    }
    return builder.build();
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant