Matteo Sessa

Add support for prefix/suffix filters on S3

......@@ -41,6 +41,16 @@ class S3EventSource(kappa.event_source.base.EventSource):
}
]
}
# Add S3 key filters
if 'key_filters' in self._config:
filters_spec = { 'Key' : { 'FilterRules' : [] } }
for filter in self._config['key_filters']:
if 'type' in filter and 'value' in filter and filter['type'] in ('prefix', 'suffix'):
rule = { 'Name' : filter['type'], 'Value' : filter['value'] }
filters_spec['Key']['FilterRules'].append(rule)
notification_spec['LambdaFunctionConfigurations'][0]['Filter'] = filters_spec
try:
response = self._s3.call(
'put_bucket_notification_configuration',
......
......@@ -34,3 +34,8 @@ lambda:
arn: arn:aws:s3:::test-1245812163
events:
- s3:ObjectCreated:*
key_filters:
- type: prefix
value: someprefix/
- type: suffix
value: .zip
......