From 6ec964f21ea201ee32462de202945fad1d1cd24d Mon Sep 17 00:00:00 2001 From: Richard Crowley Date: Mon, 6 Jun 2011 15:53:00 +0000 Subject: [PATCH 1/2] Initial import. --- index.html | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..a8f8f6e --- /dev/null +++ b/index.html @@ -0,0 +1,6 @@ + + + + + + From fb739f24edf1dde310d84e54e168612111801257 Mon Sep 17 00:00:00 2001 From: Richard Crowley Date: Mon, 6 Jun 2011 15:53:09 +0000 Subject: [PATCH 2/2] Rebuilt manual. --- man/man7/python-cloudformation.7 | 77 +++++++++++++++ python-cloudformation.7.html | 159 +++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+) create mode 100644 man/man7/python-cloudformation.7 create mode 100644 python-cloudformation.7.html diff --git a/man/man7/python-cloudformation.7 b/man/man7/python-cloudformation.7 new file mode 100644 index 0000000..ed33f62 --- /dev/null +++ b/man/man7/python-cloudformation.7 @@ -0,0 +1,77 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PYTHON\-CLOUDFORMATION" "7" "June 2011" "DevStructure" "python-cloudformation" +. +.SH "NAME" +\fBpython\-cloudformation\fR \- tools for creating CloudFormation templates +. +.SH "SYNOPSIS" +. +.nf + +import cloudformation +import sys + +t = cloudformation\.Template() +t\.Description = \'Demo of python\-cloudformation\.\' +t\.add_user_data(sys\.stdin) + +t\.Outputs\.add(\'DemoIp\', + Description=\'Public IP address of DemoInstance\', + Value={\'Fn::GetAtt\': [\'DemoInstance\', \'PublicIp\']}) + +t\.Parameters\.add(\'DemoParam\', + Description=\'DemoParam description\.\', + Type=\'String\') +t\.Parameters\.add(\'ImageId\', + Default=\'ami\-e2af508b\', + Description=\'AMI to use for all EC2 instances\.\', + Type=\'String\') +t\.Parameters\.add(\'InstanceType\', + Default=\'m1\.small\', + Description=\'Instance type to use for all EC2 instances\.\', + Type=\'String\') + +t\.Resources\.add(\'DemoInstance\', + Properties={\'ImageId\': {\'Ref\': \'ImageId\'}, + \'InstanceType\': {\'Ref\': \'InstanceType\'}, + \'KeyName\': {\'Ref\': \'KeyName\'}, + \'SecurityGroups\': [{\'Ref\': \'DemoSecurityGroup\'}], + \'UserData\': t\.ref_user_data({\'Ref\': \'DemoParam\'})}, + Type=\'AWS::EC2::Instance\') + +t\.Resources\.add(\'DemoSecurityGroup\', + Properties={ + \'GroupDescription\': \'Unrestricted SSH and HTTP\.\', + \'SecurityGroupIngress\': [{\'CidrIp\': \'0\.0\.0\.0/0\', + \'FromPort\': \'22\', + \'IpProtocol\': \'tcp\', + \'ToPort\': \'22\'}, + {\'CidrIp\': \'0\.0\.0\.0/0\', + \'FromPort\': \'80\', + \'IpProtocol\': \'tcp\', + \'ToPort\': \'80\'}]}, + Type=\'AWS::EC2::SecurityGroup\') + +print(t\.dumps()) +. +.fi +. +.SH "DESCRIPTION" +\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\." +. +.P +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\. +. +.P +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\. +. +.SH "THEME SONG" +Led Zeppelin \- "Night Flight" +. +.SH "AUTHOR" +Richard Crowley \fIrichard@devstructure\.com\fR +. +.SH "SEE ALSO" +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\. diff --git a/python-cloudformation.7.html b/python-cloudformation.7.html new file mode 100644 index 0000000..456aecf --- /dev/null +++ b/python-cloudformation.7.html @@ -0,0 +1,159 @@ + + + + + + python-cloudformation(7) - tools for creating CloudFormation templates + + + + + +
+ + + +
    +
  1. python-cloudformation(7)
  2. +
  3. python-cloudformation
  4. +
  5. python-cloudformation(7)
  6. +
+ +

NAME

+

+ python-cloudformation - tools for creating CloudFormation templates +

+ +

SYNOPSIS

+ +
import cloudformation
+import sys
+
+t = cloudformation.Template()
+t.Description = 'Demo of python-cloudformation.'
+t.add_user_data(sys.stdin)
+
+t.Outputs.add('DemoIp',
+              Description='Public IP address of DemoInstance',
+              Value={'Fn::GetAtt': ['DemoInstance', 'PublicIp']})
+
+t.Parameters.add('DemoParam',
+                 Description='DemoParam description.',
+                 Type='String')
+t.Parameters.add('ImageId',
+                 Default='ami-e2af508b',
+                 Description='AMI to use for all EC2 instances.',
+                 Type='String')
+t.Parameters.add('InstanceType',
+                 Default='m1.small',
+                 Description='Instance type to use for all EC2 instances.',
+                 Type='String')
+
+t.Resources.add('DemoInstance',
+    Properties={'ImageId': {'Ref': 'ImageId'},
+                'InstanceType': {'Ref': 'InstanceType'},
+                'KeyName': {'Ref': 'KeyName'},
+                'SecurityGroups': [{'Ref': 'DemoSecurityGroup'}],
+                'UserData': t.ref_user_data({'Ref': 'DemoParam'})},
+    Type='AWS::EC2::Instance')
+
+t.Resources.add('DemoSecurityGroup',
+    Properties={
+        'GroupDescription': 'Unrestricted SSH and HTTP.',
+        'SecurityGroupIngress': [{'CidrIp': '0.0.0.0/0',
+                                  'FromPort': '22',
+                                  'IpProtocol': 'tcp',
+                                  'ToPort': '22'},
+                                 {'CidrIp': '0.0.0.0/0',
+                                  'FromPort': '80',
+                                  'IpProtocol': 'tcp',
+                                  'ToPort': '80'}]},
+    Type='AWS::EC2::SecurityGroup')
+
+print(t.dumps())
+
+ +

DESCRIPTION

+ +

python-cloudformation 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."

+ +

After constructing a cloudformation.Template object there are two main classes of APIs available. The first is a dict/set-like API to Description, Mappings, Outputs, Parameters, and Resources. Description should be get and set as a string property. The rest may be treated like dictionaries or sets via the add method, which takes a key and arbitrary keyword arguments. These data structures will be faithfully reproduced in the JSON output.

+ +

EC2 user data is handled separately. The add_user_data 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 "____". Later, the ref_user_data method will replace the "____" markers with its positional parameters in the order they appear. Use ref_user_data as the value of the UserData key in the Properties dictionary of a Resource with Type='AWS::EC2::Instance'.

+ +

THEME SONG

+ +

Led Zeppelin - "Night Flight"

+ +

AUTHOR

+ +

Richard Crowley richard@devstructure.com

+ +

SEE ALSO

+ +

Blueprint I/O Server can create user data scripts for EC2 instance configuration. See http://devstructure.com/docs/endpoints.html#GET-user-data for more information.

+ + +
    +
  1. DevStructure
  2. +
  3. June 2011
  4. +
  5. python-cloudformation(7)
  6. +
+ +
+ +