Testing your cloud applications offline with LocalStack


Testing is an integral part of the development process in modern day applications. While working on AWS based applications, you do not want to spend hundreds of dollars by connecting to the cloud environments for testing your applications locally.  That has the potential of raising your cloud expenses quickly. But this should not be an excuse of not testing your applications.

To ease your local development process and test your applications better you can use a tool called as LocalStack.

It is open source and you can find all the details about this tool in the ReadMe file in GITHUB —https://github.com/localstack/localstack

Localstack provides all the AWS services you need for local development. You can basically run your unit tests by leveraging the AWS service instances provided by LocalStack and use it as your mocking framework. Each service listens to its own endpoint. By using LocalStack you can have access to multiple mocked instances of AWS Services.

localstack

While installing LocalStack on my mac, I bumped into couple of issues. In this blog, I will primarily explain how to resolve the issues during the installation process.

To install LocalStack you need to use a package management system called ‘pip‘. You also need to install Java, NPM and Python as a pre-requisite.

pip install localstack

Details of the error message —

Exception:

Traceback (most recent call last):

  File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py”, line 215, in main status = self.run(options, args)

IOError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/six.pyc’

This was a permission related error, and it seemed like there was write permission issue in the directory. You can use the ‘chown‘ command to change the ownership of the directory to the current user.

sudo chown -R $USER /Library/Python/2.7/site-packages/

After changing the file ownership, LocalStack was installed successfully.

Installing collected packages: localstack

Running setup.py install for localstack … done

Successfully installed localstack-0.8.4

Next step was to run the below command to start LocalStack —

localstack start

I bumped into an error again. Details of the error message —

2018-02-10T11:32:00:INFO:localstack.services.install: Downloading and installing LocalStack Java libraries. This may take some time.

ERROR: ‘which moto_server’:

Error starting infrastructure: Command ‘which moto_server’ returned non-zero exit status 1 Traceback (most recent call last):

start localstack

Reading the error message, I tried to use pip to install the moto_server by running the below command —

pip install moto[server]

 

Installing collected packages: moto

Successfully installed moto-1.2.0

Once I installed it, LocalStack came up and I was able to see the various AWS services running on different ports locally —

localstackstarted



Categories: AWS

Tags:

2 replies

  1. Ran into the same errors as you. These 2 solutions fixed it once they were run. Thanks!

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: