Mitch Garnaat

Merge pull request #33 from ryansb/develop

`update_event_sources` fails on SNS and S3 event sources
...@@ -132,18 +132,26 @@ class S3EventSource(EventSource): ...@@ -132,18 +132,26 @@ class S3EventSource(EventSource):
132 132
133 def add(self, function): 133 def add(self, function):
134 notification_spec = { 134 notification_spec = {
135 - 'CloudFunctionConfiguration': { 135 + 'LambdaFunctionConfigurations':[
136 + {
136 'Id': self._make_notification_id(function.name), 137 'Id': self._make_notification_id(function.name),
137 'Events': [e for e in self._config['events']], 138 'Events': [e for e in self._config['events']],
138 - 'CloudFunction': function.arn}} 139 + 'LambdaFunctionArn': function.arn,
140 + }
141 + ]
142 + }
139 try: 143 try:
140 - response = self._s3.put_bucket_notification( 144 + response = self._s3.put_bucket_notification_configuration(
141 Bucket=self._get_bucket_name(), 145 Bucket=self._get_bucket_name(),
142 NotificationConfiguration=notification_spec) 146 NotificationConfiguration=notification_spec)
143 LOG.debug(response) 147 LOG.debug(response)
144 - except Exception: 148 + except Exception as exc:
149 + LOG.debug(exc.response)
145 LOG.exception('Unable to add S3 event source') 150 LOG.exception('Unable to add S3 event source')
146 151
152 + def update(self, function):
153 + self.add(function)
154 +
147 def remove(self, function): 155 def remove(self, function):
148 LOG.debug('removing s3 notification') 156 LOG.debug('removing s3 notification')
149 response = self._s3.get_bucket_notification( 157 response = self._s3.get_bucket_notification(
...@@ -200,6 +208,9 @@ class SNSEventSource(EventSource): ...@@ -200,6 +208,9 @@ class SNSEventSource(EventSource):
200 except Exception: 208 except Exception:
201 LOG.exception('Unable to add SNS event source') 209 LOG.exception('Unable to add SNS event source')
202 210
211 + def update(self, function):
212 + self.add(function)
213 +
203 def remove(self, function): 214 def remove(self, function):
204 LOG.debug('removing SNS event source') 215 LOG.debug('removing SNS event source')
205 try: 216 try:
......