diff --git a/cloudify_boto3/cloudformation/resources/stack.py b/cloudify_boto3/cloudformation/resources/stack.py index 16ed362..006576f 100644 --- a/cloudify_boto3/cloudformation/resources/stack.py +++ b/cloudify_boto3/cloudformation/resources/stack.py @@ -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) @@ -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}) diff --git a/cloudify_boto3/cloudformation/tests/test_stack.py b/cloudify_boto3/cloudformation/tests/test_stack.py index 34c07bd..4232c2d 100644 --- a/cloudify_boto3/cloudformation/tests/test_stack.py +++ b/cloudify_boto3/cloudformation/tests/test_stack.py @@ -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) diff --git a/examples/cloudformation-feature-demo/blueprint.yaml b/examples/cloudformation-feature-demo/blueprint.yaml index 4d7de8f..62f7ab9 100644 --- a/examples/cloudformation-feature-demo/blueprint.yaml +++ b/examples/cloudformation-feature-demo/blueprint.yaml @@ -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" } - } - ] + }] } } }