I am connecting to SQS through my Java code, and the connection is required to be alive for more than 60 minutes, as I keep polling a queue for a long time. However the credentials I use seem to expire. How can I keep the credentials alive?
Below is how I create the credentials provider:
@Provides
public AwsCredentialsProvider getSTSCredentialProvider() {
final String credentialsPath = System.getenv("CREDENTIAL_PATH");
final AwsCredentialsProvider credentialsProvider = ProfileCredentialsProvider.builder().profileFile(
ProfileFile.builder().content(Paths.get(credentialsPath)).type(ProfileFile.Type.CREDENTIALS).build()
).profileName("default").build();
return credentialsProvider;
}
Below is how I create the SQS client:
@Provides
@Singleton
public SqsClient provideSqsClient(AwsCredentialsProvider awsCredentialsProvider) {
return SqsClient.builder().credentialsProvider(awsCredentialsProvider)
.region(REGION).build();
}
How can I allow the SQS client to refresh the credentials? Appreciate any help/guidance.