add notification arns to cloudformation

This commit is contained in:
Joseph Lawson 2014-10-29 11:59:41 -04:00
parent 2881c9b20c
commit 1152939ecd
3 changed files with 28 additions and 3 deletions

View File

@ -9,9 +9,10 @@ from .exceptions import ValidationError
class FakeStack(object):
def __init__(self, stack_id, name, template):
def __init__(self, stack_id, name, template, notification_arns=None):
self.stack_id = stack_id
self.name = name
self.notification_arns = notification_arns if notification_arns else []
self.template = template
self.status = 'CREATE_COMPLETE'
@ -39,9 +40,9 @@ class CloudFormationBackend(BaseBackend):
self.stacks = {}
self.deleted_stacks = {}
def create_stack(self, name, template):
def create_stack(self, name, template, notification_arns=None):
stack_id = generate_stack_id(name)
new_stack = FakeStack(stack_id=stack_id, name=name, template=template)
new_stack = FakeStack(stack_id=stack_id, name=name, template=template, notification_arns=notification_arns)
self.stacks[stack_id] = new_stack
return new_stack

View File

@ -12,10 +12,12 @@ class CloudFormationResponse(BaseResponse):
def create_stack(self):
stack_name = self._get_param('StackName')
stack_body = self._get_param('TemplateBody')
stack_notification_arns = self._get_multi_param('NotificationARNs.member')
stack = cloudformation_backend.create_stack(
name=stack_name,
template=stack_body,
notification_arns=stack_notification_arns
)
stack_body = {
'CreateStackResponse': {
@ -89,6 +91,15 @@ DESCRIBE_STACKS_TEMPLATE = """<DescribeStacksResult>
<StackId>{{ stack.stack_id }}</StackId>
<CreationTime>2010-07-27T22:28:28Z</CreationTime>
<StackStatus>{{ stack.status }}</StackStatus>
{% if stack.notification_arns %}
<NotificationARNs>
{% for notification_arn in stack.notification_arns %}
<member>{{ notification_arn }}</member>
{% endfor %}
</NotificationARNs>
{% else %}
<NotificationARNs/>
{% endif %}
<DisableRollback>false</DisableRollback>
<Outputs>
{% for output in stack.stack_outputs %}

View File

@ -38,6 +38,19 @@ def test_create_stack():
stack.get_template().should.equal(dummy_template)
@mock_cloudformation
def test_create_stack_with_notification_arn():
conn = boto.connect_cloudformation()
conn.create_stack(
"test_stack_with_notifications",
template_body=dummy_template_json,
notification_arns='arn:aws:sns:us-east-1:123456789012:fake-queue'
)
stack = conn.describe_stacks()[0]
[n.value for n in stack.notification_arns].should.contain('arn:aws:sns:us-east-1:123456789012:fake-queue')
@mock_cloudformation
def test_describe_stack_by_name():
conn = boto.connect_cloudformation()