add notification arns to cloudformation
This commit is contained in:
parent
2881c9b20c
commit
1152939ecd
@ -9,9 +9,10 @@ from .exceptions import ValidationError
|
|||||||
|
|
||||||
|
|
||||||
class FakeStack(object):
|
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.stack_id = stack_id
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.notification_arns = notification_arns if notification_arns else []
|
||||||
self.template = template
|
self.template = template
|
||||||
self.status = 'CREATE_COMPLETE'
|
self.status = 'CREATE_COMPLETE'
|
||||||
|
|
||||||
@ -39,9 +40,9 @@ class CloudFormationBackend(BaseBackend):
|
|||||||
self.stacks = {}
|
self.stacks = {}
|
||||||
self.deleted_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)
|
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
|
self.stacks[stack_id] = new_stack
|
||||||
return new_stack
|
return new_stack
|
||||||
|
|
||||||
|
@ -12,10 +12,12 @@ class CloudFormationResponse(BaseResponse):
|
|||||||
def create_stack(self):
|
def create_stack(self):
|
||||||
stack_name = self._get_param('StackName')
|
stack_name = self._get_param('StackName')
|
||||||
stack_body = self._get_param('TemplateBody')
|
stack_body = self._get_param('TemplateBody')
|
||||||
|
stack_notification_arns = self._get_multi_param('NotificationARNs.member')
|
||||||
|
|
||||||
stack = cloudformation_backend.create_stack(
|
stack = cloudformation_backend.create_stack(
|
||||||
name=stack_name,
|
name=stack_name,
|
||||||
template=stack_body,
|
template=stack_body,
|
||||||
|
notification_arns=stack_notification_arns
|
||||||
)
|
)
|
||||||
stack_body = {
|
stack_body = {
|
||||||
'CreateStackResponse': {
|
'CreateStackResponse': {
|
||||||
@ -89,6 +91,15 @@ DESCRIBE_STACKS_TEMPLATE = """<DescribeStacksResult>
|
|||||||
<StackId>{{ stack.stack_id }}</StackId>
|
<StackId>{{ stack.stack_id }}</StackId>
|
||||||
<CreationTime>2010-07-27T22:28:28Z</CreationTime>
|
<CreationTime>2010-07-27T22:28:28Z</CreationTime>
|
||||||
<StackStatus>{{ stack.status }}</StackStatus>
|
<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>
|
<DisableRollback>false</DisableRollback>
|
||||||
<Outputs>
|
<Outputs>
|
||||||
{% for output in stack.stack_outputs %}
|
{% for output in stack.stack_outputs %}
|
||||||
|
@ -38,6 +38,19 @@ def test_create_stack():
|
|||||||
stack.get_template().should.equal(dummy_template)
|
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
|
@mock_cloudformation
|
||||||
def test_describe_stack_by_name():
|
def test_describe_stack_by_name():
|
||||||
conn = boto.connect_cloudformation()
|
conn = boto.connect_cloudformation()
|
||||||
|
Loading…
Reference in New Issue
Block a user