-
I have two solutions, one built using .NET Core 6 and AWSSDK.3 and AWSSDK.SecurityToken Nugets, the other built using AWS S3 and AWS STS Maven packages for AWS Java SDK 2.x. Both apps are running on prem, first one on Windows, the other running on Linux container. Here are the two lines of code (excluding the library references) that gets assumes the role that I need and auto refreshes the expired token in .NET Core: using Amazon.Runtime; .. that part of the code is omitted because they are unrelated awsCredentials = new AssumeRoleAWSCredentials(new BasicAWSCredentials(_awsKey, _awsSecret), _awsRoleARN, sessionName); The following calls to get or put objects to S3 works perfectly fine. No need for anything else but the IAM key and secret. In Java on the other hand, the only way to make S3 integration work is to use the AWS CLI tool to get a token or run the code in AWS. I tried any and all sample codes I could find from Amazon and elsewhere but couldn't figure out to implement the NET Core equivalent solution where I would only need the IAM key and secret and wouldn't bother for token expiration. Here is the last version of my code which complains about the token being expired because it ignores the IAM key and secret and looks for the token in the .aws\credentials file. Is there a way to have the simplicity in Java like the one provided by AWS for the NET core world? Again, my app is running on prem so the environment is not able to handle the AWS token handling. import software.amazon.awssdk.auth.credentials.*; .. that part of the code is omitted because they are unrelated
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Turns out my debugging setup was incomplete. Here is how I resolved the issue:
-Dspring.profiles.active=local -Daws.region={myRegion} -Daws.accessKeyId={IAMKey} -Daws.secretAccessKey={IAMSecret}
import java.util.UUID; import javax.annotation.PostConstruct; import org.slf4j.LoggerFactory; import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; @service
} |
Beta Was this translation helpful? Give feedback.
Turns out my debugging setup was incomplete. Here is how I resolved the issue:
-Dspring.profiles.active=local -Daws.region={myRegion} -Daws.accessKeyId={IAMKey} -Daws.secretAccessKey={IAMSecret}
import java.util.UUID;
import javax.annotation.PostConstruct;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.somepackage.IAWSFac…