|
13 | 13 | from localstack.constants import DEFAULT_REGION
|
14 | 14 | from localstack.utils import persistence
|
15 | 15 | from localstack.utils.aws import aws_stack
|
16 |
| -from localstack.utils.common import short_uid, timestamp, TIMESTAMP_FORMAT_MILLIS, to_str, to_bytes |
| 16 | +from localstack.utils.common import short_uid, timestamp, TIMESTAMP_FORMAT_MILLIS, to_str, to_bytes, clone |
17 | 17 | from localstack.utils.analytics import event_publisher
|
18 | 18 | from localstack.services.generic_proxy import ProxyListener
|
19 | 19 |
|
@@ -383,17 +383,21 @@ def forward_request(self, method, path, data, headers):
|
383 | 383 | if method == 'PUT':
|
384 | 384 | parsed = xmltodict.parse(data)
|
385 | 385 | notif_config = parsed.get('NotificationConfiguration')
|
| 386 | + S3_NOTIFICATIONS.pop(bucket, None) |
386 | 387 | for dest in ['Queue', 'Topic', 'CloudFunction']:
|
387 | 388 | config = notif_config.get('%sConfiguration' % (dest))
|
388 | 389 | if config:
|
389 |
| - # TODO: what if we have multiple destinations - would we overwrite the config? |
| 390 | + events = config.get('Event') |
| 391 | + if isinstance(events, six.string_types): |
| 392 | + events = [events] |
390 | 393 | notification_details = {
|
391 | 394 | 'Id': config.get('Id'),
|
392 |
| - 'Event': config.get('Event'), |
| 395 | + 'Event': events, |
393 | 396 | dest: config.get(dest),
|
394 | 397 | 'Filter': config.get('Filter')
|
395 | 398 | }
|
396 |
| - S3_NOTIFICATIONS[bucket] = json.loads(json.dumps(notification_details)) |
| 399 | + # TODO: what if we have multiple destinations - would we overwrite the config? |
| 400 | + S3_NOTIFICATIONS[bucket] = clone(notification_details) |
397 | 401 |
|
398 | 402 | # return response for ?notification request
|
399 | 403 | return response
|
|
0 commit comments