seandst/cfn-pyplates — pull request #12 by zircote (2013-08-20 22:03:55+00:00)
Title: Added support for Resource Properties

This provides support for:
- [DeletionPolicy](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html)
- [DependsOn](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html)
- [MetaData](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html)
- [UpdatePolicy](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html)

In addition it address issue: seandst/cfn-pyplates#4

Example Usage:

```python
user_data_script = '''#!/bin/bash

echo "You can put your userdata script right here!"
'''

cft = CloudFormationTemplate(description="A slightly more useful template.")
properties = {
'ImageId': 'ami-c30360aa',
'InstanceType': 'm1.small',
'UserData': base64(user_data_script),
}
attributes = [
Metadata({"packages": {}, "sources": {}, "commands": {}, "files": {}, "services": {}, "users": {}, "groups": {}}),
UpdatePolicy({"MaxBatchSize": "", "MinInstancesInService": "", "PauseTime": ""}),
DeletionPolicy("Retain"),
DependsOn("myDB")
]
cft.resources.add(
Resource('MyInstance', 'AWS::EC2::Instance', properties, attributes)
)
```

Output:

```json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A slightly more useful template.",
"Resources": {
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"UserData": {
"Fn::Base64": "#!/bin/bash\n\necho \"You can put your userdata script right here!\"\n"
},
"InstanceType": "m1.small",
"ImageId": "ami-c30360aa"
},
"Metadata": {
"files": {},
"commands": {},
"users": {},
"sources": {},
"groups": {},
"services": {},
"packages": {}
},
"UpdatePolicy": {
"PauseTime": "",
"MaxBatchSize": "",
"MinInstancesInService": ""
},
"DeletionPolicy": "Retain",
"DependsOn": "myDB"
}
}
}
```