Updating s3 event sources to use new permissions feature rather than invocation role. Fixes #20.
Showing
2 changed files
with
9 additions
and
2 deletions
... | @@ -135,8 +135,7 @@ class S3EventSource(EventSource): | ... | @@ -135,8 +135,7 @@ class S3EventSource(EventSource): |
135 | 'CloudFunctionConfiguration': { | 135 | 'CloudFunctionConfiguration': { |
136 | 'Id': self._make_notification_id(function.name), | 136 | 'Id': self._make_notification_id(function.name), |
137 | 'Events': [e for e in self._config['events']], | 137 | 'Events': [e for e in self._config['events']], |
138 | - 'CloudFunction': function.arn, | 138 | + 'CloudFunction': function.arn}} |
139 | - 'InvocationRole': self._context.invoke_role_arn}} | ||
140 | try: | 139 | try: |
141 | response = self._s3.put_bucket_notification( | 140 | response = self._s3.put_bucket_notification( |
142 | Bucket=self._get_bucket_name(), | 141 | Bucket=self._get_bucket_name(), |
... | @@ -154,6 +153,7 @@ class S3EventSource(EventSource): | ... | @@ -154,6 +153,7 @@ class S3EventSource(EventSource): |
154 | fn_arn = response['CloudFunctionConfiguration']['CloudFunction'] | 153 | fn_arn = response['CloudFunctionConfiguration']['CloudFunction'] |
155 | if fn_arn == function.arn: | 154 | if fn_arn == function.arn: |
156 | del response['CloudFunctionConfiguration'] | 155 | del response['CloudFunctionConfiguration'] |
156 | + del response['ResponseMetadata'] | ||
157 | response = self._s3.put_bucket_notification( | 157 | response = self._s3.put_bucket_notification( |
158 | Bucket=self._get_bucket_name(), | 158 | Bucket=self._get_bucket_name(), |
159 | NotificationConfiguration=response) | 159 | NotificationConfiguration=response) | ... | ... |
... | @@ -22,6 +22,13 @@ lambda: | ... | @@ -22,6 +22,13 @@ lambda: |
22 | timeout: 3 | 22 | timeout: 3 |
23 | mode: event | 23 | mode: event |
24 | test_data: input.json | 24 | test_data: input.json |
25 | + permissions: | ||
26 | + - | ||
27 | + statement_id: s3_invoke | ||
28 | + action: lambda:invokeFunction | ||
29 | + principal: s3.amazonaws.com | ||
30 | + # change this to refer to your own SNS topic | ||
31 | + source_arn: arn:aws:s3:::test-1245812163 | ||
25 | event_sources: | 32 | event_sources: |
26 | - | 33 | - |
27 | arn: arn:aws:s3:::test-1245812163 | 34 | arn: arn:aws:s3:::test-1245812163 | ... | ... |
-
Please register or login to post a comment