Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gas-buddy/configured-sns-client
A configuration driven SNS client
https://github.com/gas-buddy/configured-sns-client
Last synced: about 2 months ago
JSON representation
A configuration driven SNS client
- Host: GitHub
- URL: https://github.com/gas-buddy/configured-sns-client
- Owner: gas-buddy
- Created: 2020-08-11T03:22:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-24T00:15:43.000Z (about 4 years ago)
- Last Synced: 2024-04-15T00:45:48.871Z (9 months ago)
- Language: JavaScript
- Size: 173 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
configured-sns-client
==========================![Node CI](https://github.com/gas-buddy/configured-sns-client/workflows/Node%20CI/badge.svg)
A small wrapper around the AWS SNS sdk to allow configuration from confit. This module focuses on publishing and consuming messages. Topic configuration for SNS is done OUTSIDE of this module (assumedly will be terraform or similar).
Usage
=====
To send a message, you must configure this module in your service```
{
"region": "us-east-1",
"accountId": "1234",
"module": "require:@gasbuddy/configured-sns-client"
}
```Now, you can publish to a topic (Note: Your service's role must have permission to pubish to the SNS topic)
```
configuredSnsClient.publish(req, 'topic', { some: 'message' });// OR (with message attributes)
configuredSnsClient.publish(req, 'topic', { some: 'message' }, {
MessageAttributes: {
Event_Type: {
DataType: 'String.Array',
StringValue: JSON.stringify(['user.registered']),
},
},
});
```You can set `assumedRole` to assert that your service has that role at the time of hydration
```
{
"assumedRole": "abc-topic-publisher",
"region": "us-east-1",
....
}
```