bbc/localstack

Name: localstack

Owner: BBC

Description: ? A fully functional local AWS cloud stack. Develop and test your cloud apps offline!

Created: 2018-05-17 07:58:28.0

Updated: 2018-05-17 07:58:31.0

Pushed: 2018-05-11 19:13:45.0

Homepage: https://localstack.cloud

Size: 1732

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status Backers on Open Collective Sponsors on Open Collective Coverage Status Gitter PyPI Version PyPI License Code Climate Twitter

LocalStack - A fully functional local AWS cloud stack

LocalStack

LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications.

Currently, the focus is primarily on supporting the AWS cloud stack.

Announcements

Overview

LocalStack spins up the following core Cloud APIs on your local machine:

Additionally, LocalStack provides a powerful set of tools to interact with the cloud services, including a fully featured KCL Kinesis client with Python binding, simple setup/teardown integration for nosetests, as well as an Environment abstraction that allows to easily switch between local and remote Cloud execution.

Why LocalStack?

LocalStack builds on existing best-of-breed mocking/testing tools, most notably kinesalite/dynalite and moto. While these tools are awesome (!), they lack functionality for certain use cases. LocalStack combines the tools, makes them interoperable, and adds important missing functionality on top of them:

Requirements
Installing

The easiest way to install LocalStack is via pip:

install localstack

Once installed, run the infrastructure using the following command:

lstack start

Note: Please do not use sudo or the root user - LocalStack should be installed and started entirely under a local non-root user. If you have problems with permissions in MacOS X Sierra, install with pip install --user localstack

Running in Docker

You can also spin up LocalStack in Docker:

lstack start --docker

(Note that on MacOS you may have to run TMPDIR=/private$TMPDIR localstack start --docker if $TMPDIR contains a symbolic link that cannot be mounted by Docker.)

Or using docker-compose (you need to clone the repository first):

er-compose up

(Note that on MacOS you may have to run TMPDIR=/private$TMPDIR docker-compose up if $TMPDIR contains a symbolic link that cannot be mounted by Docker.)

Configurations

You can pass the following environment variables to LocalStack:

Additionally, the following read-only environment variables are available:

Accessing the infrastructure via CLI or code

You can point your aws CLI to use the local infrastructure, for example:

--endpoint-url=http://localhost:4568 kinesis list-streams

"StreamNames": []

NEW: Check out awslocal, a thin CLI wrapper that runs commands directly against LocalStack (no need to specify --endpoint-url anymore). Install it via pip install awscli-local, and then use it as follows:

ocal kinesis list-streams

"StreamNames": []

UPDATE: Use the environment variable $LOCALSTACK_HOSTNAME to determine the target host inside your Lambda function. See Configurations section for more details.

Client Libraries
Integration with nosetests

If you want to use LocalStack in your integration tests (e.g., nosetests), simply fire up the infrastructure in your test setup method and then clean up everything in your teardown method:

 localstack.services import infra

setup():
infra.start_infra(async=True)

teardown():
infra.stop_infra()

my_app_test():
# here goes your test logic

See the example test file tests/test_integration.py for more details.

Integration with Java/JUnit

In order to use LocalStack with Java, the project ships with a simple JUnit runner. Take a look at the example JUnit test in ext/java. When you run the test, all dependencies are automatically downloaded and installed to a temporary directory in your system.


rt cloud.localstack.LocalstackTestRunner;
rt cloud.localstack.TestUtils;

With(LocalstackTestRunner.class)
ic class MyCloudAppTest {

est
blic void testLocalS3API() {
AmazonS3 s3 = TestUtils.getClientS3()
List<Bucket> buckets = s3.listBuckets();
...



Additionally, there is a version of the LocalStack Test Runner which runs in a docker container instead of installing LocalStack on the current machine. The only dependency is to have docker installed locally. The test runner will automatically pull the image and start the container for the duration of the test. The container can be configured by using the @LocalstackDockerProperties annotation.

With(LocalstackDockerTestRunner.class)
alstackDockerProperties(randomizePorts = true, services = { "sqs", "kinesis:77077" })
ic class MyDockerCloudAppTest {

est
blic void testKinesis() {
AmazonKinesis kinesis = DockerTestUtils.getClientKinesis();

ListStreamsResult streams = kinesis.listStreams();
...

The LocalStack JUnit test runner is published as an artifact in Maven Central. Simply add the following dependency to your pom.xml file:

endency>
<groupId>cloud.localstack</groupId>
<artifactId>localstack-utils</artifactId>
<version>0.1.13</version>
pendency>
Troubleshooting
Developing

If you pull the repo in order to extend/modify LocalStack, run this command to install all the dependencies:

 install

This will install the required pip dependencies in a local Python virtualenv directory .venv (your global python packages will remain untouched), as well as some node modules in ./localstack/node_modules/. Depending on your system, some pip/npm modules may require additional native libs installed.

The Makefile contains a target to conveniently run the local infrastructure for development:

 infra

Check out the developer guide which contains a few instructions on how to get started with developing (and debugging) features for LocalStack.

Testing

The project contains a set of unit and integration tests that can be kicked off via a make target:

 test
Web Dashboard

The projects also comes with a simple Web dashboard that allows to view the deployed AWS components and the relationship between them.

lstack web
Change Log
Contributing

We welcome feedback, bug reports, and pull requests!

For pull requests, please stick to the following guidelines:

Please note that by contributing any code or documentation to this repository (by raising pull requests, or otherwise) you explicitly agree to the Contributor License Agreement.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! ? [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

Copyright (c) 2017 LocalStack maintainers and contributors.

Copyright (c) 2016 Atlassian and others.

This version of LocalStack is released under the Apache License, Version 2.0 (see LICENSE.txt). By downloading and using this software you agree to the End-User License Agreement (EULA).

We build on a number of third-party software tools, with the following licenses:

Third-Party software | License —————————-|———————– Python/pip modules: | airspeed | BSD License amazon_kclpy | Amazon Software License boto3 | Apache License 2.0 coverage | Apache License 2.0 docopt | MIT License elasticsearch | Apache License 2.0 flask | BSD License flask_swagger | MIT License jsonpath-rw | Apache License 2.0 moto | Apache License 2.0 nose | GNU LGPL pep8 | Expat license requests | Apache License 2.0 subprocess32 | PSF License Node.js/npm modules: | kinesalite | MIT License Other tools: | Elasticsearch | Apache License 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.