Welcome to Subdivisions
AWS Eventbridge backed PubSub solution
Install in Project
- Install subdivisions
$ pip install sub-divisions
Configure Project
- On every project which you will send or receive messages, create a
pyproject.tomlwith the following configuration:
[tool.subdivisions]
source_name = "ProjectName" # For Eventbridge Schema Discovery
aws_account = "" # AWS Account Id
aws_user = "" # AWS User with sufficient permissions
The source_name are used to inform the Source field in Eventbridge
messages. This source will be used on Eventbridge discovery schemas.
The aws_account is the AWS account which will be configured for
Eventbridge, KMS, SNS and SQS artifacts.
The aws_user is the user which we will use for create the KMS PubSub
Key. To avoid conflicts use the AWS Secret Key and AWS Secret Id
from the same user. This account must have the minimum permissions:
- Allow all Eventbridge actions
- Allow all SQS actions
- Allow all SNS actions
- Allow all KMS actions
Usage
Send Messages
from enum import unique, Enum
from subdivisions.client import SubClient
@unique
class MyProjectEvents(Enum):
MY_EXAMPLE_EVENT = "my_example_event"
client = SubClient()
client.topic = MyProjectEvents.MY_EXAMPLE_EVENT
client.send({"foo": "bar"})
Receive Messages
from enum import unique, Enum
from subdivisions.client import SubClient
@unique
class MyProjectEvents(Enum):
MY_EXAMPLE_EVENT = "my_example_event"
client = SubClient()
client.topic = MyProjectEvents.MY_EXAMPLE_EVENT
messages = client.get_messages() # use the ``from_dead_letter=True` to receive Dead Letter messages
# Process messages
client.delete_received_messages()
AWS Credentials
Subdivisions will use AWS default environment variables. If you need to define another credentials, use the following variables:
SUBDIVISIONS_USE_AWS_ENV_VARS="false"
SUBDIVISIONS_AWS_ACCESS_KEY_ID="your id"
SUBDIVISIONS_AWS_SECRET_ACCESS_KEY="your key"
SUBDIVISIONS_AWS_SESSION_TOKEN="your token" # optional
Configuration
Configure subdivisions options in pyproject.toml file, inside [tool.subdivisions] table:
# pyproject.toml
[tool.subdivisions]
aws_region = "us-east-1" # AWS Region
aws_account = "" # AWS Account for configuration/use
aws_user = "" # AWS User with sufficient permissions
aws_sqs_policy = "" # AWS SQS Policy (default in policies.py)
aws_sns_policy = "" # AWS SNS Policy (default in policies.py)
aws_kms_policy = "" # AWS KMS Policy (default in policies.py)
pub_key = "PubSubKey" # KMS PubSubKey (must be created first)
sqs_tags = [] # SQS tags for new queues. Example [{"foo": "bar"}]
queue_prefix = "" # Prefix for new SQS queues
queue_suffix = "" # Suffix for new SQS queues
queue_max_receive_count = 1000 # SQS MaxReceiveCount setting
sns_prefix = "" # Prefix for new SNS topics
sns_suffix = "" # Suffix for new SNS topics
sns_tags = [] # SNS tags for new topics. Example [{"foo": "bar"}]
event_prefix = "" # Prefix for new Eventbride rules
event_suffix = "" # Suffix for new Eventbride rules
event_tags = [] # Eventbridge tags for new rules. Example [{"foo": "bar"}]
event_bus = "default" # Eventbridge Bus
source_name = "" # Eventbridge default source name. No default, must inform
auto_create_new_topic = true # Auto create new topic if not exists in Eventbridge
auto_remove_from_queue = false # Acknowledge first messages on receive
use_aws_env_vars = true # Use AWS default env vars. If false append "SUBDIVISION_" on env vars. Example: "SUBDIVISION_AWS_ACCESS_KEY_ID"
default_prefix = "pubsub" # Default prefix for all sns, sqs and rule created
default_suffix = "" # Default suffix for all sns, sqs and rule created
All options above can be configured in environment variables. Just append SUBDIVISIONS_ on name. Example: SUBDIVISIONS_SOURCE_NAME="my_project"
Metadata
Release files for sub-divisions 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sub-divisions-1.0.2.tar.gz | 13.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sub_divisions-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.1 kB
Release files / sub-divisions-1.0.2.tar.gz
| Download URL | sub-divisions-1.0.2.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95f1caf150a006409547d1033dcd25ad3ed5f6db50bfed4744379880bb5e59a6
|
|
BLAKE2b-256 checksum How to use checksums |
58ca31159b2026a5aa1809b9deaa064ee881cbdcafecc8b107c455dd98e1ecb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.8.0 tqdm/4.60.0 CPython/3.7.10
|
Release files / sub_divisions-1.0.2-py3-none-any.whl
| Download URL | sub_divisions-1.0.2-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a784768b7778e4a5231252ebf4947e5cd5341e68d0f002f6883b2cfea52621cf
|
|
BLAKE2b-256 checksum How to use checksums |
b727cd975cd61ed5a4a00006aa782ce17c01648c00d114445689f53ebefd6540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.8.0 tqdm/4.60.0 CPython/3.7.10
|
Security for sub-divisions 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.