Description
Describe the bug
We are using aws sso to get session credentials. Wehn we use this we can use the Jaka SDK to query S3 etc., but are failing to be able to do anything with SQS utilising the Java SDK v2, although the AWS CLI and Python apps work just fine..
Our basic issue is we received a 403 error when calling the API, for example to list queues and a message of the form 'Access to the resource https://sqs.eu-west-1.amazonaws.com/ is denied'
Expected Behavior
AWS SDK v2 interacting with SQS when we are logged on via aws sso should allow interations to just work.
Current Behavior
We receive a 403 error when calling the API, for example to list queues and a message of the form 'Access to the resource https://sqs.eu-west-1.amazonaws.com/ is denied'
Reproduction Steps
Log in to AWS using SSO against a profile other than default. This profile uses a different role specifc to what we need to do.
Using code as per
SqsClient sqs = SqsClient.builder()
.region(Region.EU_WEST_1)
.credentialsProvider(DefaultCredentialsProvider.builder().profileName("dev-profile").build())
.build();
ListQueuesResponse lq_result = sqs.listQueues(ListQueuesRequest.builder().build()); // fails here
for (String url : lq_result.queueUrls()) {
System.out.println(url);
}
Possible Solution
No response
Additional Information/Context
We have used the AWS CLI to connect and this work.
aws sqs list-queues --profile=dev-profile
We have also used a small python script, below, and this also works
import boto3
# Create SQS client
session = boto3.Session(profile_name='dev-profile')
sqs = session.client('sqs')
# List SQS queues
response = sqs.list_queues()
print(response['QueueUrls'])
AWS Java SDK version used
2.20.34
JDK version used
openjdk version "1.8.0_342" OpenJDK Runtime Environment Corretto-8.342.07.3 (build 1.8.0_342-b07) OpenJDK 64-Bit Server VM Corretto-8.342.07.3 (build 25.342-b07, mixed mode)
Operating System and version
Windows 10