Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localstack AWS endpoint in application

I would like to run the functional tests for my application which tries to publish a message to AWS SNS. I tried LocalStack and found that it does everything I need to mock and publish messages locally. But my application uses amazon sdk client for java and when I run it locally it still tries to post requests to amazon region instead of the LocalStack

What is the configuration required to make sure that the application interacts with the local stack instead of the AWS URL? Can we specify the endpoint URL in AWS config? I found this to be a open issue in AWS CLI https://github.com/aws/aws-cli/issues/1270

Is there any workaround that anyone has implemented for this?

like image 912
Pratik Shelar Avatar asked Nov 13 '17 22:11

Pratik Shelar


People also ask

How do I connect to LocalStack?

Get a desktop experience and work with your local LocalStack instance via the UI. Use the docker CLI to manually start the LocalStack Docker container. Use docker-compose to configure and start your LocalStack Docker container. Use helm to create a LocalStack deployment in a Kubernetes cluster.

Can I use LocalStack without Docker?

Running LocalStack outside of Docker LocalStack is a standalone application and can be run outside of Docker but it doesn't support every operating system.

How does LocalStack work?

Simply put, LocalStack is an open-source mock of the real AWS services. It provides a testing environment on our local machine with the same APIs as the real AWS services. We switch to using the real AWS services only in the integration environment and beyond.

Does LocalStack have a UI?

To start using LocalStack, check out our documentation on docs.localstack.cloud. To use LocalStack with a graphical user interface, you can use the following UI clients: Commandeer desktop app. DynamoDB Admin Web UI.


1 Answers

To use your localstack, you have to set your EndpointConfiguration.

AmazonSNS amazonSNS = AmazonSNSClientBuilder.standard()
  .withEndpointConfiguration(new EndpointConfiguration("http://localhost:4575", "eu-west-1")) 
  .build();

You should also use localstack/localstack instead of atlassian/localstack (no longer actively maintained).

like image 63
Guillaume Vauvert Avatar answered Oct 15 '22 12:10

Guillaume Vauvert