Merge pull request #2 from nonspecialist/develop
Support for environment variable credentials; handle stack creation failure
Showing
2 changed files
with
13 additions
and
2 deletions
... | @@ -40,6 +40,9 @@ Where ``command`` is one of: | ... | @@ -40,6 +40,9 @@ Where ``command`` is one of: |
40 | The ``config file`` is a YAML format file containing all of the information | 40 | The ``config file`` is a YAML format file containing all of the information |
41 | about your Lambda function. | 41 | about your Lambda function. |
42 | 42 | ||
43 | +If you use environment variables for your AWS credentials (as normally supported by boto), | ||
44 | +simply exclude the ``profile`` element from the YAML file. | ||
45 | + | ||
43 | An example project based on a Kinesis stream can be found in | 46 | An example project based on a Kinesis stream can be found in |
44 | [samples/kinesis](https://github.com/garnaat/kappa/tree/develop/samples/kinesis). | 47 | [samples/kinesis](https://github.com/garnaat/kappa/tree/develop/samples/kinesis). |
45 | 48 | ||
... | @@ -56,4 +59,4 @@ The basic workflow is: | ... | @@ -56,4 +59,4 @@ The basic workflow is: |
56 | * Run ``kappa --config <path-to-config> tail`` to see more output | 59 | * Run ``kappa --config <path-to-config> tail`` to see more output |
57 | 60 | ||
58 | If you have to make changes in your function or in your IAM roles, simply run | 61 | If you have to make changes in your function or in your IAM roles, simply run |
59 | -``kappa deploy`` again and the changes will be uploaded as necessary. | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
62 | +``kappa deploy`` again and the changes will be uploaded as necessary. | ... | ... |
... | @@ -25,11 +25,16 @@ LOG = logging.getLogger(__name__) | ... | @@ -25,11 +25,16 @@ LOG = logging.getLogger(__name__) |
25 | class Kappa(object): | 25 | class Kappa(object): |
26 | 26 | ||
27 | completed_states = ('CREATE_COMPLETE', 'UPDATE_COMPLETE') | 27 | completed_states = ('CREATE_COMPLETE', 'UPDATE_COMPLETE') |
28 | + failed_states = ('ROLLBACK_COMPLETE') | ||
28 | 29 | ||
29 | def __init__(self, config): | 30 | def __init__(self, config): |
30 | self.config = config | 31 | self.config = config |
31 | self.session = botocore.session.get_session() | 32 | self.session = botocore.session.get_session() |
32 | - self.session.profile = config['profile'] | 33 | + # otherwise, assume we'll use environment variables |
34 | + if 'profile' in config: | ||
35 | + self.session.profile = config['profile'] | ||
36 | + else: | ||
37 | + self.session.profile = None | ||
33 | self.region = config['region'] | 38 | self.region = config['region'] |
34 | 39 | ||
35 | def create_update_roles(self, stack_name, roles_path): | 40 | def create_update_roles(self, stack_name, roles_path): |
... | @@ -63,6 +68,8 @@ class Kappa(object): | ... | @@ -63,6 +68,8 @@ class Kappa(object): |
63 | LOG.debug('Stack status is: %s', status) | 68 | LOG.debug('Stack status is: %s', status) |
64 | if status in self.completed_states: | 69 | if status in self.completed_states: |
65 | done = True | 70 | done = True |
71 | + if status in self.failed_states: | ||
72 | + raise ValueError('Could not create stack %s: %s' % (stack_name, status)) | ||
66 | 73 | ||
67 | def get_role_arn(self, role_name): | 74 | def get_role_arn(self, role_name): |
68 | role_arn = None | 75 | role_arn = None |
... | @@ -231,6 +238,7 @@ class Kappa(object): | ... | @@ -231,6 +238,7 @@ class Kappa(object): |
231 | self.config['lambda']['zipfile_name'], | 238 | self.config['lambda']['zipfile_name'], |
232 | self.config['lambda']['path']) | 239 | self.config['lambda']['path']) |
233 | self.upload_lambda_function(self.config['lambda']['zipfile_name']) | 240 | self.upload_lambda_function(self.config['lambda']['zipfile_name']) |
241 | + self.add_event_source() | ||
234 | 242 | ||
235 | def test(self): | 243 | def test(self): |
236 | self._invoke_asynch(self.config['lambda']['test_data']) | 244 | self._invoke_asynch(self.config['lambda']['test_data']) | ... | ... |
-
Please register or login to post a comment