-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lambda][alert] adding support for sns as a source #119
Conversation
cdc205e
to
4c9de29
Compare
@@ -67,8 +67,8 @@ def validate_config(config): | |||
|
|||
# check sources attributes | |||
elif config_key == 'sources': | |||
if not set(settings.keys()).issubset(set(['kinesis', 's3'])): | |||
raise ConfigError('Sources missing kinesis or s3 keys') | |||
if not set(settings.keys()).issubset(set(['kinesis', 's3', 'sns'])): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing set([])
let's just do {}
@@ -130,11 +130,14 @@ def map_source(self, payload): | |||
payload.service = 'kinesis' | |||
elif 's3' in payload.raw_record: | |||
payload.service = 's3' | |||
elif 'Sns' in payload.raw_record: | |||
payload.service = 'sns' | |||
|
|||
# map the entity name from a record | |||
entity_mapper = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#simplify (discussed offline)
5803ad8
to
4c9de29
Compare
Updating tests to include sns sources.
4c9de29
to
b6cb86b
Compare
@@ -86,6 +88,12 @@ def s3_process(self, payload, classifier): | |||
classifier.classify_record(payload, data) | |||
self.process_alerts(payload) | |||
|
|||
def sns_process(self, payload, classifier): | |||
"""Process SNS data for alerts""" | |||
data = StreamPreParsers.pre_parse_sns(payload.raw_record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method looks almost the same as the kinesis pre parser, can we simplify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a small change, but it just mostly consolidates duplicate code into a method. The pre_parse..
methods pull data from different keys, so this is about as simple as this get (see pre_parsers.py
for more context).
df89c55
to
d29a645
Compare
d29a645
to
57bfccc
Compare
to @airbnb/streamalert-maintainers
size: small
work in progress for #64
changes