Mitch Garnaat

Merge pull request #29 from garnaat/delete-log-group

Delete the log group when the function is deleted.
...@@ -152,6 +152,7 @@ class Context(object): ...@@ -152,6 +152,7 @@ class Context(object):
152 def delete(self): 152 def delete(self):
153 for event_source in self.event_sources: 153 for event_source in self.event_sources:
154 event_source.remove(self.function) 154 event_source.remove(self.function)
155 + self.function.log.delete()
155 self.function.delete() 156 self.function.delete()
156 time.sleep(5) 157 time.sleep(5)
157 if self.role: 158 if self.role:
......
...@@ -13,10 +13,12 @@ ...@@ -13,10 +13,12 @@
13 13
14 import logging 14 import logging
15 15
16 -LOG = logging.getLogger(__name__) 16 +from botocore.exceptions import ClientError
17 17
18 import kappa.aws 18 import kappa.aws
19 19
20 +LOG = logging.getLogger(__name__)
21 +
20 22
21 class Log(object): 23 class Log(object):
22 24
...@@ -61,3 +63,11 @@ class Log(object): ...@@ -61,3 +63,11 @@ class Log(object):
61 logStreamName=latest_stream['logStreamName']) 63 logStreamName=latest_stream['logStreamName'])
62 LOG.debug(response) 64 LOG.debug(response)
63 return response['events'] 65 return response['events']
66 +
67 + def delete(self):
68 + try:
69 + response = self._log_svc.delete_log_group(
70 + logGroupName=self.log_group_name)
71 + LOG.debug(response)
72 + except ClientError:
73 + LOG.debug('unable to delete log group')
......