How to deal with connection to cloud systems in dev and test mode?

tldr; I want to know what a good strategy could be for developing/testing when an application connects to cloud service.

The issue

I inherited a phoenix application that connects to AWS IoT. I need to do changes an bug fixes.
When I boot up the application in DEV mode on the console (iex -S mix phx.server) errors appear because the connection fails to the AWS IoT service.

The phoenix/elixir/vue application connects to AWS IoT via Tortoise. Tortoise does not give me an option to ‘fake’ the connection, the only thing I could find is verify: :verify_none but that’;s only for the ca certificates, the connection is still being done.

As the application does not boot up because of the errors, it’s hard to make any changes/bug fixes.

Possible solutions I can think of

  1. using something like LocalStack · GitHub. In that case, connection will be done to a localstack docker container. The production code can stay as is, only need config changes. Issue I have with that is that it is more difficult to mock several scenarios, and pro version is needed, and in a trial period the API keys are not available.
  2. Mock the Tortoise dep, so I will not really connect, but I will use different code than in production.

Question

So the question is: what is the better way to handle 3rd party connections?

Thx in advance.

It’s hard to say without knowing more about the “application” structure. Can’t you just disable/exclude that process/part of supervision tree in dev and test?

That is possible, but that would lead to if statements all over the place. Hence the idea of the Mock version.