Use SNS Bridge to connect your local development for Chalice apps to Amazon SNS
- An HTTP server is started on your local machine
- An ngrok tunnel is opened to the HTTP server
- SNS Bridge subscribes the ngrok tunnel to your SNS topic
- When a message is received, your SNS function is imported and called. This is done in a separate process each time to allow hot reloading.
- When finished, SNS bridge cleans up after itself and unsubscribes from the topic. Assuming you don't force quit.
- Setup an ngrok account.
- Download and install their CLI tool and set your API key.
Using Poetry (recommended):
poetry add --dev sns_bridge
If using PIP (not recommended as the SNS Bridge requirements might pollute your Chalice app requierements):
pip install sns_bridge
You may always use sns_bridge --help
to access this information.
Usage: sns_bridge [OPTIONS]
Options:
--role-arn TEXT ARN of the role to assume
--port INTEGER Port number to run
--topic-name TEXT SNS topic name [required]
--help Show this message and exit.
The only required parameter, this is the name of the SNS topic you wish to subscribe to.
Optional. If you are using a multi-tier AWS account setup that requires you to "switch" or "assume" roles in order to work with resources, pass the appropriate role ARN here.
Optional. Defaults to a very high port number, 65500. Pass in a new port number if necessary.