<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kevininscoe.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Troposphere</id>
	<title>Troposphere - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://kevininscoe.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Troposphere"/>
	<link rel="alternate" type="text/html" href="https://kevininscoe.com/wiki/index.php?title=Troposphere&amp;action=history"/>
	<updated>2026-06-02T03:29:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://kevininscoe.com/wiki/index.php?title=Troposphere&amp;diff=345&amp;oldid=prev</id>
		<title>Kinscoe: Created page with &quot;==What is Troposphere==  Troposphere is a Python library to create AWS CloudFormation descriptions  ==Why would I use it?==  At some point you get tired of hand rolling JSON u...&quot;</title>
		<link rel="alternate" type="text/html" href="https://kevininscoe.com/wiki/index.php?title=Troposphere&amp;diff=345&amp;oldid=prev"/>
		<updated>2017-03-29T19:33:21Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==What is Troposphere==  Troposphere is a Python library to create AWS CloudFormation descriptions  ==Why would I use it?==  At some point you get tired of hand rolling JSON u...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==What is Troposphere==&lt;br /&gt;
&lt;br /&gt;
Troposphere is a Python library to create AWS CloudFormation descriptions&lt;br /&gt;
&lt;br /&gt;
==Why would I use it?==&lt;br /&gt;
&lt;br /&gt;
At some point you get tired of hand rolling JSON using Vim or an editor. Also you wish to share common components between environments, and especially repeated resources perhaps such as a NAT in each AZ or perhaps a required Security Group (like HMH SSH SG) in new environments with repeatability. The later requiring scoped IP addresses for the internal HMH network.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;troposphere allows you to describe AWS CloudFormation stacks in Python. You can then generate your JSON. The main advantage here for me was keeping my stack definitions DRY. Instead of doing the same thing over and over again in JSON, I just define it once in Python and import it when I need it.&amp;quot; -- http://dustinrcollins.com/infrastructure-with-python&lt;br /&gt;
&lt;br /&gt;
A deep knowledge of Python is really not needed the same as knowing Ruby is not a requirement of knowing Chef. However having said that I did find knowing Python [https://docs.python.org/2/library/functions.html Built-in Functions] useful when you [https://github.com/cloudtools/troposphere/blob/master/troposphere/ec2.py lookup properties. For example in ec2.py]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class SecurityGroup(AWSObject):&lt;br /&gt;
    resource_type = &amp;quot;AWS::EC2::SecurityGroup&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    props = {&lt;br /&gt;
        &amp;#039;GroupDescription&amp;#039;: (basestring, True),&lt;br /&gt;
        &amp;#039;SecurityGroupEgress&amp;#039;: (list, False),&lt;br /&gt;
        &amp;#039;SecurityGroupIngress&amp;#039;: (list, False),&lt;br /&gt;
        &amp;#039;VpcId&amp;#039;: (basestring, False),&lt;br /&gt;
        &amp;#039;Tags&amp;#039;: (list, False),&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will need to understand how to format a basestring, list, etc..&lt;br /&gt;
&lt;br /&gt;
==How can I get it?==&lt;br /&gt;
&lt;br /&gt;
It can be found here https://github.com/cloudtools/troposphere or installing using pip:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ (sudo) (-H) pip install troposphere (--upgrade)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Give me some examples ==&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s say given our example above we have a certain set of IP addresses we wish to allow SSH access to and that pattern is repeatable in nearly all AWS environments.&lt;br /&gt;
&lt;br /&gt;
One would write the following brief Python code to create the Cloud Formation template usable in all environments (but you must specify the VPC ID):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Renders CFN JSON to create an HMH SSH internal Security group&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Import troposphere&lt;br /&gt;
from troposphere import Template, Ref, Output, Join, GetAtt, Parameter&lt;br /&gt;
import troposphere.ec2 as ec2&lt;br /&gt;
&lt;br /&gt;
# Create a template for resources to live in&lt;br /&gt;
template = Template()&lt;br /&gt;
&lt;br /&gt;
# Create a security group&lt;br /&gt;
sg = ec2.SecurityGroup(&amp;#039;SSHInternal&amp;#039;)&lt;br /&gt;
sg.GroupDescription = &amp;quot;Allow SSH access to approved internal networks&amp;quot;&lt;br /&gt;
sg.VpcId = &amp;#039;vpc-34ce3351&amp;#039;&lt;br /&gt;
sg.SecurityGroupIngress = [&lt;br /&gt;
    ec2.SecurityGroupRule(&lt;br /&gt;
        IpProtocol=&amp;quot;tcp&amp;quot;,&lt;br /&gt;
        FromPort=&amp;quot;22&amp;quot;,&lt;br /&gt;
        ToPort=&amp;quot;22&amp;quot;,&lt;br /&gt;
        CidrIp=&amp;quot;10.82.0.0/16,10.87.0.0/0&amp;quot;,&lt;br /&gt;
    )]&lt;br /&gt;
&lt;br /&gt;
# Add security group to template&lt;br /&gt;
template.add_resource(sg)&lt;br /&gt;
&lt;br /&gt;
# Print out CloudFormation template in JSON&lt;br /&gt;
print template.to_json()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Yields&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Resources&amp;quot;: {&lt;br /&gt;
        &amp;quot;HMHSSHInternal&amp;quot;: {&lt;br /&gt;
            &amp;quot;Properties&amp;quot;: {&lt;br /&gt;
                &amp;quot;GroupDescription&amp;quot;: &amp;quot;Allow SSH access to approved HMH internal networks&amp;quot;,&lt;br /&gt;
                &amp;quot;SecurityGroupIngress&amp;quot;: [&lt;br /&gt;
                    {&lt;br /&gt;
                        &amp;quot;CidrIp&amp;quot;: &amp;quot;10.82.0.0/16,155.44.0.0/0&amp;quot;,&lt;br /&gt;
                        &amp;quot;FromPort&amp;quot;: &amp;quot;22&amp;quot;,&lt;br /&gt;
                        &amp;quot;IpProtocol&amp;quot;: &amp;quot;tcp&amp;quot;,&lt;br /&gt;
                        &amp;quot;ToPort&amp;quot;: &amp;quot;22&amp;quot;&lt;br /&gt;
                    }&lt;br /&gt;
                ],&lt;br /&gt;
                &amp;quot;VpcId&amp;quot;: &amp;quot;vpc-34ce3351&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            &amp;quot;Type&amp;quot;: &amp;quot;AWS::EC2::SecurityGroup&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I learn more? ==&lt;br /&gt;
&lt;br /&gt;
*Documentation (not much) can be found at http://troposphere.readthedocs.org/en/stable/&lt;br /&gt;
*Community: Troposphere has a google group, [https://groups.google.com/forum/#!forum/cloudtools-dev cloudtools-dev], where you can ask questions and engage with the troposphere community.&lt;br /&gt;
&lt;br /&gt;
== The case for Python ==&lt;br /&gt;
&lt;br /&gt;
http://dustinrcollins.com/infrastructure-with-python&lt;/div&gt;</summary>
		<author><name>Kinscoe</name></author>
	</entry>
</feed>