
igeshosk/localstack, they lack functionality for certain use cases. LocalStack combines the tools, makes them interoperable, and adds important missing functionality on top of them:
ProvisionedThroughputExceededException which is thrown by Kinesis or DynamoDB if the amount of
read/write throughput is exceeded.@mock_sqs. These client proxies
do not perform an actual REST call, but rather call a local mock service method that lives in the same process as
the test code.makepython (both Python 2.x and 3.x supported)pip (python package manager)npm (node.js package manager)java/javac (Java 8 runtime environment and compiler)mvn (Maven, the build system for Java)The easiest way to install LocalStack is via pip:
pip install localstack
Once installed, run the infrastructure using the following command:
localstack start
You can also spin up LocalStack in Docker:
localstack start --docker
Or using docker-compose (you need to clone the repository first):
docker-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.)
You can pass the following environment variables to LocalStack:
SERVICES: Comma-separated list of service names and (optional) ports they should run on.
If no port is specified, a default port is used. Service names basically correspond to the
service names of the AWS CLI
(kinesis, lambda, sqs, etc), although LocalStack only supports a subset of them.
Example value: kinesis,lambda:4569,sqs:4570 to start Kinesis on the default port,
Lambda on port 4569, and SQS on port 4570.DEFAULT_REGION: AWS region to use when talking to the API (defaults to us-east-1).HOSTNAME: If you need to expose your services on a specific host
(defaults to localhost).USE_SSL: Whether to use [***] URLs with SSL encryption (defaults to false).KINESIS_ERROR_PROBABILITY: Decimal value between 0.0 (default) and 1.0 to randomly
inject ProvisionedThroughputExceededException errors into Kinesis API responses.DYNAMODB_ERROR_PROBABILITY: Decimal value between 0.0 (default) and 1.0 to randomly
inject ProvisionedThroughputExceededException errors into DynamoDB API responses.LAMBDA_EXECUTOR: Method to use for executing Lambda functions. Valid values are local (run
the code in a temporary directory on the local machine) or docker (run code in a separate
Docker container). In the latter case, if LocalStack itself is started inside Docker, then
the docker command needs to be available inside the container (usually requires to run the
container in privileged mode). Default is docker, fallback to local if Docker is not available.LAMBDA_REMOTE_DOCKER:
false (default): your lambda functions definitions will be passed to the container by
mounting the volume (potentially faster) It is mandatory to have the Docker client and the Docker
host on the same machinetrue: your lambda functions definitions will be passed to the container by
copying the zip file (potentially slower). It allows for remote execution, where the host
and the client are not on the same machineDATA_DIR: Local directory for saving persistent data (currently only supported for these services:
Kinesis, DynamoDB, Elasticsearch). Set it to /tmp/localstack/data to enable persistence
(/tmp/localstack is mounted into the Docker container), leave blank to disable
persistence (default).You can point your aws CLI to use the local infrastructure, for example:
aws --endpoint-url=http://localhost:4568 kinesis list-streams { "StreamNames": [] }
If you are accessing the cloud APIs from within yout Python code, you can also use boto3 and use
the endpoint_url parameter to connect to the respective service on localhost.
See localstack.utils.aws.aws_stack for convenience methods to connect to the local services.
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:
from localstack.mock import infra def setup(): infra.start_infra(async=True) def teardown(): infra.stop_infra() def my_app_test(): # here goes your test logic
See the example test file tests/test_integration.py for more details.
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.
@RunWith(LocalstackTestRunner.class) public class MyCloudAppTest { @Test public void testLocalS3API() { AmazonS3 s3 = new AmazonS3Client(...); s3.setEndpoint(LocalstackTestRunner.getEndpointS3()); List<Bucket> buckets = s3.listBuckets(); ... } }
The LocalStack JUnit test runner is published as a Maven artifact in the Bitbucket repository.
Simply add the following configuration to your pom.xml file:
<project ...> ... <dependencies> ... <dependency> <groupId>com.atlassian</groupId> <artifactId>localstack-utils</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <repositories> <repository> <id>localstack-repo</id> <url>[***]</url> </repository> </repositories> </project>
If you're using AWS Java libraries with Kinesis, please, refer to CBOR protocol issues with the Java SDK guide how to disable CBOR protocol which is not supported by kinesalite.
Accessing local S3 from Java: To avoid domain name resolution issues, you need to enable path style access on your client:
s3.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build()); // There is also an option to do this if you're using any of the client builder classes: AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard(); builder.withPathStyleAccessEnabled(true); ...
TMPDIR=/private$TMPDIR docker-compose up if
$TMPDIR contains a symbolic link that cannot be mounted by Docker.
(See details here: [***]If you pull the repo in order to extend/modify LocalStack, run this command to install all the dependencies:
make 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:
make infra
The project contains a set of unit and integration tests that can be kicked off via a make target:
make test
The projects also comes with a simple Web dashboard that allows to view the deployed AWS components and the relationship between them.
localstack web
USE_SSL config); create Docker base image; fix issue with DATA_DIRWe welcome feedback, bug reports, and pull requests!
For pull requests, please stick to the following guidelines:
Please note that we need to collect a signed Contributors License Agreement from each individual developer who contributes code to this repository. Please refer to the following links:
Copyright (c) 2016 Atlassian and others.
LocalStack is released under the Apache License, Version 2.0 (see LICENSE.txt).
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 |
| sh | MIT License |
| subprocess32 | PSF License |
| Node.js/npm modules: | |
| dynalite | MIT License |
| kinesalite | MIT License |
| Other tools: | |
| Elasticsearch | Apache License 2.0 |





manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务