seandst/cfn-pyplates — pull request #10 by zircote (2013-08-19 21:32:07+00:00)
Title: Providing support for metadata

This will provide metadaa support for various activities in the template
such as:

- http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html
- http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html
- and others

Created objects:
- `core.Metadata`
- `core.Metadatums`
- supporting tests

Examples:
cfn_pyplates
```python
cft = CloudFormationTemplate(description="A slightly more useful template.")

cft.resources.add(
Resource('MyS3Bucket', 'AWS::S3::Bucket', None, Metadata(
{"Object1": "Location1", "Object2": "Location2"}
))
)
```
Output:
```json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A slightly more useful template.",
"Resources": {
"MyS3Bucket": {
"Type": "AWS::S3::Bucket",
"Metadata": {
"Object1": "Location1",
"Object2": "Location2"
}
}
}
}
```
Examples 2:

cfn_pyplates:

```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),
}
metadata = Metadata(
{"packages": {}, "sources": {}, "commands": {}, "files": {}, "services": {}, "users": {}, "groups": {}})
cft.resources.add(
Resource('MyInstance', 'AWS::EC2::Instance', properties, metadata)
)
```
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": {}
}
}
}
}
```