From 8b4154938da5ca1ca7d52225cb2d3fc623e2b9cb Mon Sep 17 00:00:00 2001 From: Njal Karevoll Date: Wed, 19 Sep 2012 16:37:50 +0200 Subject: [PATCH 1/2] Test that NotificationARNs are parsed correctly --- tests/unit/cloudformation/test_connection.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/unit/cloudformation/test_connection.py b/tests/unit/cloudformation/test_connection.py index 9de5b52836..d7f86c70b4 100644 --- a/tests/unit/cloudformation/test_connection.py +++ b/tests/unit/cloudformation/test_connection.py @@ -379,6 +379,9 @@ def default_body(self): CAPABILITY_IAM + + arn:aws:sns:region-name:account-name:topic-name + false @@ -410,12 +413,15 @@ def default_body(self): def test_describe_stacks(self): self.set_http_response(status_code=200) - stack = self.service_connection.describe_stacks('MyStack')[0] + + stacks = self.service_connection.describe_stacks('MyStack') + self.assertEqual(len(stacks), 1) + + stack = stacks[0] self.assertEqual(stack.creation_time, datetime(2012, 5, 16, 22, 55, 31)) self.assertEqual(stack.description, 'My Description') self.assertEqual(stack.disable_rollback, True) - self.assertEqual(stack.notification_arns, []) self.assertEqual(stack.stack_id, 'arn:aws:cfn:us-east-1:1:stack') self.assertEqual(stack.stack_status, 'CREATE_COMPLETE') self.assertEqual(stack.stack_name, 'MyStack') @@ -434,6 +440,9 @@ def test_describe_stacks(self): self.assertEqual(len(stack.capabilities), 1) self.assertEqual(stack.capabilities[0].value, 'CAPABILITY_IAM') + self.assertEqual(len(stack.notification_arns), 1) + self.assertEqual(stack.notification_arns[0].value, 'arn:aws:sns:region-name:account-name:topic-name') + self.assertEqual(len(stack.tags), 1) self.assertEqual(stack.tags['MyTagKey'], 'MyTagValue') From c5973b34f3290ae6a688030f891c379e8e54ac5d Mon Sep 17 00:00:00 2001 From: Njal Karevoll Date: Wed, 19 Sep 2012 16:39:04 +0200 Subject: [PATCH 2/2] Support for cloudformation stacks that uses SNS for notifications --- boto/cloudformation/stack.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/boto/cloudformation/stack.py b/boto/cloudformation/stack.py index e1a1d6b5e4..9a9d63b50b 100644 --- a/boto/cloudformation/stack.py +++ b/boto/cloudformation/stack.py @@ -33,6 +33,9 @@ def startElement(self, name, attrs, connection): elif name == "Tags": self.tags = Tag() return self.tags + elif name == 'NotificationARNs': + self.notification_arns = ResultSet([('member', NotificationARN)]) + return self.notification_arns else: return None @@ -43,8 +46,6 @@ def endElement(self, name, value, connection): self.description = value elif name == "DisableRollback": self.disable_rollback = bool(value) - elif name == "NotificationARNs": - self.notification_arns = value elif name == 'StackId': self.stack_id = value elif name == 'StackName': @@ -212,6 +213,21 @@ def endElement(self, name, value, connection): setattr(self, name, value) +class NotificationARN(object): + def __init__(self, connection=None): + self.connection = None + self.value = None + + def startElement(self, name, attrs, connection): + return None + + def endElement(self, name, value, connection): + self.value = value + + def __repr__(self): + return "NotificationARN:\"%s\"" % (self.value) + + class StackResource(object): def __init__(self, connection=None): self.connection = connection