Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ future==0.16.0
futures==3.2.0; python_version < '3'
hjson==3.0.1
jmespath==0.9.3
kappa==0.6.0
kappa==0.7.0
lambda-packages==0.20.0
pip>=9.0.1, <=10.1.0
python-dateutil>=2.6.1, <2.7.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"status_code": 200,
"data": {
"items": [
{
"description": "Api Key for rdrde6pecd",
"enabled": true,
"stageKeys": [
"rdrde6pecd/devor"
],
"lastUpdatedDate": 1470384739,
"createdDate": 1470384739,
"id": "W9QTptojpE3bsg816Rrjh4was83amtaAx5s6NXaAl",
"name": "devor_rdrde6pecd"
}
]
}
}
4 changes: 2 additions & 2 deletions tests/tests_placebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from zappa.cli import ZappaCLI
from zappa.handler import LambdaHandler
from zappa.utilities import (add_event_source, remove_event_source)
from zappa.utilities import (add_event_source, get_event_source_status, remove_event_source)
from zappa.core import Zappa


Expand Down Expand Up @@ -462,8 +462,8 @@ def test_add_event_source(self, session):
"s3:ObjectCreated:*"
]}
add_event_source(event_source, 'lambda:lambda:lambda:lambda', 'test_settings.callback', session, dry=True)
get_event_source_status(event_source, 'lambda:lambda:lambda:lambda', 'test_settings.callback', session, dry=True)
remove_event_source(event_source, 'lambda:lambda:lambda:lambda', 'test_settings.callback', session, dry=True)
# get_event_source_status(event_source, 'lambda:lambda:lambda:lambda', 'test_settings.callback', session, dry=True)

@placebo_session
def test_cognito_trigger(self, session):
Expand Down
33 changes: 12 additions & 21 deletions zappa/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,17 @@ def add(self, function):
if self.filters:
self.add_filters(function)

class ExtendedS3EventSource(kappa.event_source.s3.S3EventSource):
# https://github.com/garnaat/kappa/pull/120
def _make_notification_id(self, function_name):
import hashlib
id_no = self._config.get('id', hashlib.md5(bytes(self._config)).hexdigest()[:8])
return 'Kappa-%s-notification-%s' % (function_name, id_no)

event_source_map = {
'dynamodb': kappa.event_source.dynamodb_stream.DynamoDBStreamEventSource,
'kinesis': kappa.event_source.kinesis.KinesisEventSource,
's3': kappa.event_source.s3.S3EventSource,
's3': ExtendedS3EventSource,
'sns': ExtendedSnsEventSource,
'events': kappa.event_source.cloudwatch.CloudWatchEventSource
}
Expand All @@ -258,31 +265,15 @@ def add(self, function):
def autoreturn(self, function_name):
return function_name

event_source_func._make_notification_id = autoreturn
if svc != 's3':
event_source_func._make_notification_id = autoreturn

ctx = PseudoContext()
ctx.session = boto_session

funk = PseudoFunction()
funk.name = lambda_arn

# Kappa 0.6.0 requires this nasty hacking,
# hopefully we can remove at least some of this soon.
# Kappa 0.7.0 introduces a whole host over other changes we don't
# really want, so we're stuck here for a little while.

# Related: https://github.com/Miserlou/Zappa/issues/684
# https://github.com/Miserlou/Zappa/issues/688
# https://github.com/Miserlou/Zappa/commit/3216f7e5149e76921ecdf9451167846b95616313
if svc == 's3':
split_arn = lambda_arn.split(':')
arn_front = ':'.join(split_arn[:-1])
arn_back = split_arn[-1]
ctx.environment = arn_back
funk.arn = arn_front
funk.name = ':'.join([arn_back, target_function])
else:
funk.arn = lambda_arn
funk.arn = lambda_arn

funk._context = ctx

Expand Down Expand Up @@ -421,4 +412,4 @@ def titlecase_keys(d):
"""
Takes a dict with keys of type str and returns a new dict with all keys titlecased.
"""
return {k.title(): v for k, v in d.items()}
return {k.title(): v for k, v in d.items()}