Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Commit

Permalink
improved the json dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
EarthmanT committed Jun 26, 2017
1 parent 7174cb2 commit 081de58
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
9 changes: 5 additions & 4 deletions cloudify_boto3/cloudformation/resources/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def create(ctx, iface, resource_config, **_):
stack_name = params.get(NAME)
utils.update_resource_id(ctx.instance, stack_name)

template_body = params.get(TEMPLATEBODY)
template_body = params.get(TEMPLATEBODY, {})
if not isinstance(template_body, basestring):
params[TEMPLATEBODY] = json.dumps(template_body)

Expand All @@ -116,6 +116,7 @@ def delete(iface, resource_config, **_):
# Create a copy of the resource config for clean manipulation.
params = \
dict() if not resource_config else resource_config.copy()
if NAME not in params.keys():
params.update({NAME: iface.resource_id})
iface.delete(params)
name = params.get(NAME)
if not name:
name = iface.resource_id
iface.delete({NAME: name})
4 changes: 2 additions & 2 deletions cloudify_boto3/cloudformation/tests/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def test_create(self):
create_stack.\
assert_called_with(
StackName='test-cloudformation1',
TemplateBody={"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template"})
TemplateBody=str({"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template"}))

self.assertEqual(_ctx.instance.runtime_properties,
RUNTIMEPROP_AFTER_CREATE)
Expand Down
36 changes: 17 additions & 19 deletions examples/cloudformation-feature-demo/blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,24 @@ node_templates:
StackName: test-cloudformation1
TemplateBody:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "A sample template",
"Resources" : {
"MyEC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : "ami-876facc3",
"InstanceType" : "t1.micro",
"KeyName" : "testkey",
"BlockDeviceMappings" : [
{
"DeviceName" : "/dev/sdm",
"Ebs" : {
"VolumeType" : "io1",
"Iops" : "200",
"DeleteOnTermination" : "false",
"VolumeSize" : "20"
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template",
"Resources": {
"MyEC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-876facc3",
"InstanceType": "t1.micro",
"KeyName": "testkey",
"BlockDeviceMappings": [{
"DeviceName": "/dev/sdm",
"Ebs": {
"VolumeType": "io1",
"Iops": "200",
"DeleteOnTermination": "false",
"VolumeSize": "20"
}
}
]
}]
}
}
}
Expand Down

0 comments on commit 081de58

Please sign in to comment.