Using Skaffold and LocalStack to Develop Cloud Applications Locally
You’ve just decided to start building on services hosted for you by your cloud provider. Great! However, you will soon realize, that building applications locally against these APIs can be challenging. Should each developer create a development environment for themselves in the cloud? Will you test against a staging environment? Will you mock them out all the time?
Sadly, each of these solutions has their drawbacks. Wouldn’t it be great to run your version of the cloud services you need locally? LocalStack can do that for you.
LocalStack provides an easy-to-use test/mocking framework for developing cloud applications - currently for AWS only.
- Error injection: with LocalStack, you can inject errors that will occur in the real environment as well, like
- HTTP services: all LocalStack AWS service implementations are exposed through a REST API; this also means, that you can use the AWS CLI with them,
- Language agnostic: as LocalStack exposes HTTP services, you can use them with any languages.
Sounds exciting? Let’s see how you can set it up for your machine!
When it comes to running LocalStack, you have some options:
installing all of its’ dependencies, and run the Python application,
- running a Docker image,
- running a Kubernetes service with Skaffold.
As LocalStack has many dependencies (like pip, npm, java or mvn), I wouldn’t recommend installing them locally.
To run the docker image, you will have to clone the LocalStack repository first, then spin up the service with
# cloning the repository
Looks a lot cleaner than installing all the dependencies, right? However, if you use Kubernetes, and you’d like this to be the part of the local development workflow without starting it manually, or cloning it, you can take this to the next level with Skaffold. If you are not familiar with that, I’d recommend reading the Using Kubernetes for Local Development article before continue reading this article.
Let’s start with the deployment first:
Once we have deployment, we have to expose them using a service:
If you’d like, you can put these manifests into a single file, with the
--- used as a separator. Once you have all these in place, the only thing you have to do is to update your
skaffold.yml file so that Skaffold can pick up your new changes.
I hope this article helps you to build cloud applications easier locally! Please share your thoughts below in the comments section! 😊
What are your thoughts on developing cloud applications locally using tools like LocalStack? How do you handle it?