-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
SQS doesn't work with AWS SDK 2.0 #1318
Comments
How did you create the v2 credentials? I got SQS v2 to work with this Scala code: import java.net.URI
import cloud.localstack.DockerTestUtils
import cloud.localstack.TestUtils.{DEFAULT_REGION, TEST_ACCESS_KEY, TEST_SECRET_KEY}
import cloud.localstack.docker.annotation.LocalstackDockerProperties
import cloud.localstack.docker.{LocalstackDocker, LocalstackDockerTestRunner}
import org.junit.Test
import org.junit.runner.RunWith
import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.sqs.SqsClient
import scala.collection.JavaConverters._
@RunWith(classOf[LocalstackDockerTestRunner])
@LocalstackDockerProperties(imageTag = "0.9.4", randomizePorts = true, services = Array("sqs"))
class LocalstackITCase {
private val credsV2 = StaticCredentialsProvider.create(AwsBasicCredentials.create(TEST_ACCESS_KEY, TEST_SECRET_KEY))
private val sqsEndPoint = LocalstackDocker.INSTANCE.getEndpointSQS
@Test
def testSQSv2(): Unit = {
val sqs: SqsClient = SqsClient.builder
.endpointOverride(new URI(sqsEndPoint))
.region(Region.of(DEFAULT_REGION))
.credentialsProvider(credsV2)
.build()
println(sqs.listQueues())
}
} |
@seanf i did just like you, except that localstack is ran as docker container
Scala code val credsV2 = StaticCredentialsProvider.create(AwsBasicCredentials.create("accesskey", "secretkey"))
val sqsClient = SqsAsyncClient
.builder()
.region(Region.EU_CENTRAL_1)
.credentialsProvider(credsV2)
.build() |
@highflyerDL That JUnit runner uses a Docker container too. I got the same error as you when I added an async test based on your code: @Test
def otherTest(): Unit = {
val sqsClient = SqsAsyncClient
.builder()
// .endpointOverride(new URI(sqsEndPoint)) // without this, you'll get a security token error
.region(Region.EU_CENTRAL_1)
.credentialsProvider(credsV2)
.build()
println(sqsClient.listQueues().get().toString)
} You're just missing the endpoint setting on the SqsAsyncClient, probably http://localhost:4576 in your setup. |
@seanf That works. Thanks ! |
I'm having 2 SQS Java clients, 1 with SDK 1 and the other with the new SDK 2.0. For some reason, the new SDK couldn't work with local SQS because of the following error
even though the credentials being used are the same. Tried to use the solution proposed in #893 (comment) but it didn't work still.
The text was updated successfully, but these errors were encountered: