| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is an easy-to-use Python client for LocalStack. The client library provides a thin wrapper around boto3 which automatically configures the target endpoints to use LocalStack for your local cloud application development.
To make use of this library, you need to have LocalStack installed on your local machine. In particular, the localstack command needs to be available.
The easiest way to install LocalStack is via pip:
pip install localstack-client
This library provides an API that is identical to boto3's. A minimal way to try it out is to replace import boto3 with import localstack_client.session as boto3. This will allow your boto3 calls to work as normal. For example, to list all s3 buckets in localstack:
import localstack_client.session as boto3
client = boto3.client('s3')
response = client.list_buckets()
Another example below shows using localstack_client directly. To list the SQS queues in your local (LocalStack) environment, use the following code:
import localstack_client.session
session = localstack_client.session.Session()
sqs = session.client('sqs')
assert sqs.list_queues() is not None
If you use boto3.client directly in your code, you can mock it.
import localstack_client.session
import pytest
@pytest.fixture(autouse=True)
def boto3_localstack_patch(monkeypatch):
session_ls = localstack_client.session.Session()
monkeypatch.setattr(boto3, "client", session_ls.client)
monkeypatch.setattr(boto3, "resource", session_ls.resource)
sqs = boto3.client('sqs')
assert sqs.list_queues() is not None # list SQS in localstack
We welcome feedback, bug reports, and pull requests!
Use these commands to get you started and test your code:
make install make test
The LocalStack Python Client is released under the Apache License, Version 2.0 (see LICENSE).
| Back | FazBrowse Home | New Git URL |