|
| 1 | +.\" generated with Ronn/v0.7.3 |
| 2 | +.\" http://github.com/rtomayko/ronn/tree/0.7.3 |
| 3 | +. |
| 4 | +.TH "PYTHON\-CLOUDFORMATION" "7" "July 2011" "DevStructure" "python-cloudformation" |
| 5 | +. |
| 6 | +.SH "NAME" |
| 7 | +\fBpython\-cloudformation\fR \- tools for creating CloudFormation templates |
| 8 | +. |
| 9 | +.SH "SYNOPSIS" |
| 10 | +. |
| 11 | +.nf |
| 12 | + |
| 13 | +import cloudformation |
| 14 | +import sys |
| 15 | + |
| 16 | +t = cloudformation\.Template() |
| 17 | +t\.Description = \'Demo of python\-cloudformation\.\' |
| 18 | +t\.add_user_data(sys\.stdin) |
| 19 | + |
| 20 | +t\.Outputs\.add(\'DemoIp\', |
| 21 | + Description=\'Public IP address of DemoInstance\', |
| 22 | + Value={\'Fn::GetAtt\': [\'DemoInstance\', \'PublicIp\']}) |
| 23 | + |
| 24 | +t\.Parameters\.add(\'DemoParam\', |
| 25 | + Description=\'DemoParam description\.\', |
| 26 | + Type=\'String\') |
| 27 | +t\.Parameters\.add(\'ImageId\', |
| 28 | + Default=\'ami\-e2af508b\', |
| 29 | + Description=\'AMI to use for all EC2 instances\.\', |
| 30 | + Type=\'String\') |
| 31 | +t\.Parameters\.add(\'InstanceType\', |
| 32 | + Default=\'m1\.small\', |
| 33 | + Description=\'Instance type to use for all EC2 instances\.\', |
| 34 | + Type=\'String\') |
| 35 | + |
| 36 | +t\.Resources\.add(\'DemoInstance\', |
| 37 | + Properties={\'ImageId\': {\'Ref\': \'ImageId\'}, |
| 38 | + \'InstanceType\': {\'Ref\': \'InstanceType\'}, |
| 39 | + \'KeyName\': {\'Ref\': \'KeyName\'}, |
| 40 | + \'SecurityGroups\': [{\'Ref\': \'DemoSecurityGroup\'}], |
| 41 | + \'UserData\': t\.ref_user_data({\'Ref\': \'DemoParam\'})}, |
| 42 | + Type=\'AWS::EC2::Instance\') |
| 43 | + |
| 44 | +t\.Resources\.add(\'DemoSecurityGroup\', |
| 45 | + Properties={ |
| 46 | + \'GroupDescription\': \'Unrestricted SSH and HTTP\.\', |
| 47 | + \'SecurityGroupIngress\': [{\'CidrIp\': \'0\.0\.0\.0/0\', |
| 48 | + \'FromPort\': \'22\', |
| 49 | + \'IpProtocol\': \'tcp\', |
| 50 | + \'ToPort\': \'22\'}, |
| 51 | + {\'CidrIp\': \'0\.0\.0\.0/0\', |
| 52 | + \'FromPort\': \'80\', |
| 53 | + \'IpProtocol\': \'tcp\', |
| 54 | + \'ToPort\': \'80\'}]}, |
| 55 | + Type=\'AWS::EC2::SecurityGroup\') |
| 56 | + |
| 57 | +print(t\.dumps()) |
| 58 | +. |
| 59 | +.fi |
| 60 | +. |
| 61 | +.SH "DESCRIPTION" |
| 62 | +\fBpython\-cloudformation\fR transforms Python source code representations of AWS CloudFormation templates into JSON\. It\'s most useful for automating tedious user data manipulation in its very rudimentary "templating language\." |
| 63 | +. |
| 64 | +.P |
| 65 | +After constructing a \fBcloudformation\.Template\fR object there are two main classes of APIs available\. The first is a \fBdict\fR/\fBset\fR\-like API to \fBDescription\fR, \fBMappings\fR, \fBOutputs\fR, \fBParameters\fR, and \fBResources\fR\. \fBDescription\fR should be get and set as a string property\. The rest may be treated like dictionaries or sets via the \fBadd\fR method, which takes a \fBkey\fR and arbitrary keyword arguments\. These data structures will be faithfully reproduced in the JSON output\. |
| 66 | +. |
| 67 | +.P |
| 68 | +EC2 user data is handled separately\. The \fBadd_user_data\fR method accepts a file\-like object which it reads, parses, and stores for later\. The parsing step is very rudimentary: it splits the input on "\fB____\fR"\. Later, the \fBref_user_data\fR method will replace the "\fB____\fR" markers with its positional parameters in the order they appear\. Use \fBref_user_data\fR as the value of the \fBUserData\fR key in the \fBProperties\fR dictionary of a \fBResource\fR with \fBType=\'AWS::EC2::Instance\'\fR\. |
| 69 | +. |
| 70 | +.SH "THEME SONG" |
| 71 | +Led Zeppelin \- "Night Flight" |
| 72 | +. |
| 73 | +.SH "AUTHOR" |
| 74 | +Richard Crowley \fIrichard@devstructure\.com\fR |
| 75 | +. |
| 76 | +.SH "SEE ALSO" |
| 77 | +Blueprint I/O Server can create user data scripts for EC2 instance configuration\. See \fIhttp://devstructure\.com/docs/endpoints\.html#GET\-user\-data\fR for more information\. |
0 commit comments