I am trying to create an SQS queue for an integration test and Localstack ends up creating the queue on a different port every time. I need to hard code this URL so that the downstream applications can pick it up from a config. Is there a way to ensure that the queue creation happens on a predefined port?
Code for queue creation:
SqsAsyncClient sqsAsyncClient = SqsAsyncClient.builder()
.endpointOverride(localstack.getEndpointOverride(LocalStackContainer.Service.SQS))
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(
localstack.getAccessKey(), localstack.getSecretKey()
)))
.region(Region.US_EAST_1)
.build();
CreateQueueRequest createQueueRequest = CreateQueueRequest.builder()
.queueName("sample-queue")
.build();
String queueUrl = sqsAsyncClient.createQueue(createQueueRequest)
.get()
.queueUrl();
System.out.println("## URL: " + queueUrl);
The url being logged is always on a different port. Couple of runs show the log as below:
## URL: http://localhost:53380/queue/sample-queue
## URL: http://localhost:53566/queue/sample-queue
Note that I don’t have any docker container running for Localstack and above is the only config in my codebase.