Showing
5 changed files
with
27 additions
and
4 deletions
... | @@ -34,7 +34,7 @@ from kappa.context import Context | ... | @@ -34,7 +34,7 @@ from kappa.context import Context |
34 | @click.argument( | 34 | @click.argument( |
35 | 'command', | 35 | 'command', |
36 | required=True, | 36 | required=True, |
37 | - type=click.Choice(['deploy', 'test', 'tail', 'add-event-source', 'delete']) | 37 | + type=click.Choice(['deploy', 'test', 'tail', 'add-event-sources', 'delete']) |
38 | ) | 38 | ) |
39 | def main(config=None, debug=False, command=None): | 39 | def main(config=None, debug=False, command=None): |
40 | ctx = Context(config, debug) | 40 | ctx = Context(config, debug) |
... | @@ -54,7 +54,7 @@ def main(config=None, debug=False, command=None): | ... | @@ -54,7 +54,7 @@ def main(config=None, debug=False, command=None): |
54 | click.echo('Deleting ...') | 54 | click.echo('Deleting ...') |
55 | ctx.delete() | 55 | ctx.delete() |
56 | click.echo('...done') | 56 | click.echo('...done') |
57 | - elif command == 'add-event-source': | 57 | + elif command == 'add-event-sources': |
58 | click.echo('Adding event sources ...') | 58 | click.echo('Adding event sources ...') |
59 | ctx.add_event_sources() | 59 | ctx.add_event_sources() |
60 | click.echo('...done') | 60 | click.echo('...done') | ... | ... |
... | @@ -100,6 +100,15 @@ class S3EventSource(EventSource): | ... | @@ -100,6 +100,15 @@ class S3EventSource(EventSource): |
100 | LOG.exception('Unable to add S3 event source') | 100 | LOG.exception('Unable to add S3 event source') |
101 | 101 | ||
102 | def remove(self, function): | 102 | def remove(self, function): |
103 | + LOG.debug('removing s3 notification') | ||
103 | response = self._s3.get_bucket_notification( | 104 | response = self._s3.get_bucket_notification( |
104 | Bucket=self._get_bucket_name()) | 105 | Bucket=self._get_bucket_name()) |
105 | LOG.debug(response) | 106 | LOG.debug(response) |
107 | + if 'CloudFunctionConfiguration' in response: | ||
108 | + fn_arn = response['CloudFunctionConfiguration']['CloudFunction'] | ||
109 | + if fn_arn == function.arn: | ||
110 | + del response['CloudFunctionConfiguration'] | ||
111 | + response = self._s3.put_bucket_notification( | ||
112 | + Bucket=self._get_bucket_name(), | ||
113 | + NotificationConfiguration=response) | ||
114 | + LOG.debug(response) | ... | ... |
... | @@ -26,8 +26,18 @@ class Log(object): | ... | @@ -26,8 +26,18 @@ class Log(object): |
26 | aws = kappa.aws.get_aws(self._context) | 26 | aws = kappa.aws.get_aws(self._context) |
27 | self._log_svc = aws.create_client('logs') | 27 | self._log_svc = aws.create_client('logs') |
28 | 28 | ||
29 | + def _check_for_log_group(self): | ||
30 | + LOG.debug('checking for log group') | ||
31 | + response = self._log_svc.describe_log_groups() | ||
32 | + log_group_names = [lg['logGroupName'] for lg in response['logGroups']] | ||
33 | + return self.log_group_name in log_group_names | ||
34 | + | ||
29 | def streams(self): | 35 | def streams(self): |
30 | LOG.debug('getting streams for log group: %s', self.log_group_name) | 36 | LOG.debug('getting streams for log group: %s', self.log_group_name) |
37 | + if not self._check_for_log_group(): | ||
38 | + LOG.info( | ||
39 | + 'log group %s has not been created yet', self.log_group_name) | ||
40 | + return [] | ||
31 | response = self._log_svc.describe_log_streams( | 41 | response = self._log_svc.describe_log_streams( |
32 | logGroupName=self.log_group_name) | 42 | logGroupName=self.log_group_name) |
33 | LOG.debug(response) | 43 | LOG.debug(response) |
... | @@ -35,6 +45,10 @@ class Log(object): | ... | @@ -35,6 +45,10 @@ class Log(object): |
35 | 45 | ||
36 | def tail(self): | 46 | def tail(self): |
37 | LOG.debug('tailing log group: %s', self.log_group_name) | 47 | LOG.debug('tailing log group: %s', self.log_group_name) |
48 | + if not self._check_for_log_group(): | ||
49 | + LOG.info( | ||
50 | + 'log group %s has not been created yet', self.log_group_name) | ||
51 | + return [] | ||
38 | latest_stream = None | 52 | latest_stream = None |
39 | streams = self.streams() | 53 | streams = self.streams() |
40 | for stream in streams: | 54 | for stream in streams: | ... | ... |
... | @@ -5,7 +5,7 @@ from setuptools import setup, find_packages | ... | @@ -5,7 +5,7 @@ from setuptools import setup, find_packages |
5 | import os | 5 | import os |
6 | 6 | ||
7 | requires = [ | 7 | requires = [ |
8 | - 'botocore==0.80.0', | 8 | + 'botocore==0.82.0', |
9 | 'click==3.3', | 9 | 'click==3.3', |
10 | 'PyYAML>=3.11' | 10 | 'PyYAML>=3.11' |
11 | ] | 11 | ] | ... | ... |
-
Please register or login to post a comment