Merge pull request #923 from JackDanger/jack/cloud-formation-yaml

Allow yaml templates for cloud formation
This commit is contained in:
Steve Pulec 2017-05-12 18:41:46 -04:00 committed by GitHub
commit 0fe824277b
3 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from datetime import datetime
import json
import yaml
import uuid
import boto.cloudformation
@ -18,7 +19,7 @@ class FakeStack(BaseModel):
self.stack_id = stack_id
self.name = name
self.template = template
self.template_dict = json.loads(self.template)
self._parse_template()
self.parameters = parameters
self.region_name = region_name
self.notification_arns = notification_arns if notification_arns else []
@ -71,6 +72,12 @@ class FakeStack(BaseModel):
resource_properties=resource_properties,
))
def _parse_template(self):
try:
self.template_dict = yaml.load(self.template)
except yaml.parser.ParserError:
self.template_dict = json.loads(self.template)
@property
def stack_parameters(self):
return self.resource_map.resolved_parameters

View File

@ -12,6 +12,7 @@ install_requires = [
"dicttoxml",
"six",
"werkzeug",
"pyaml",
"pytz",
"python-dateutil",
]

View File

@ -1,5 +1,6 @@
from __future__ import unicode_literals
import json
import yaml
from mock import patch
import sure # noqa
@ -126,6 +127,20 @@ def test_parse_stack_with_name_type_resource():
queue.should.be.a(Queue)
def test_parse_stack_with_yaml_template():
stack = FakeStack(
stack_id="test_id",
name="test_stack",
template=yaml.dump(name_type_template),
parameters={},
region_name='us-west-1')
stack.resource_map.should.have.length_of(1)
list(stack.resource_map.keys())[0].should.equal('Queue')
queue = list(stack.resource_map.values())[0]
queue.should.be.a(Queue)
def test_parse_stack_with_outputs():
stack = FakeStack(
stack_id="test_id",