Run AWS on your localhost

There is no debate about cloud in general and AWS in particular without hearing that development and testing are complicated because your application is coupled with the services it uses. Even though this is something true, it is not such a big deal. There are more approaches to solve this, each having its pros and cons:

  • create a development environment for dev team. If this has the advantage of replicating perfectly the production environment, it comes with an extra cost plus, for some services makes the development/debugging more complicated: imagine that you share an SQS queue with your colleague and when you send a message, it messes up his application. Creating a stack for each developer is not a scalable solution and developers are not the most organized beings in the world, leaving behind plenty of unused resources, but consuming money.
  • Use service mocks. A while ago we discussed about DynamoDB Local, but plenty of similar frameworks exists for the most popular AWS services. This approach comes with zero cost, but with the trouble of managing a new dependency and, if you are not lucky or you need advanced features, you can notice it’s not supported.

We spent some time investigating several solutions and one was quite interesting for us: localstack. This framework was originally developed by Atlassian and now it seems to be supported by the community.

Localstack logoWhy we loved it so much:

  • almost all popular services are supported
  • it can run as a separate application and not as a library in our application, so less dependencies to maintain
  • support for Java is quite good, even integration with JUnit 5 being offered
  • it supports AWS CLI
  • specifically for S3 we tested many frameworks, but we weren’t able to find one that supports bucket versioning. Localstack does that.

Just to mention the minuses:

  • installation on Mac is not so trivial as it described in the documentation, but if you struggle a little, we are sure you win. If we manage, anyone does. 🙂
  • the “console” provided is a joke, but you can handle the resources by using AWS CLI and /or the SDK. Actually, the CLI usage is very simple, you just have to use the local endpoint:
aws --endpoint-url=http://localhost:4572 s3 mb s3://my-bucket

We encourage you to test this framework. If you notice any issue or if you have experience with other frameworks that emulates AWS services, share it with the entire community!

Happy AWS-ing!