Using troposphere to create a Python script for our template

We will first install the troposphere library:

$ pip install troposphere  

Once the installation is done, you can then create a new file called helloworld-cf-template.py.

We will start our file by importing a number of definitions from the troposphere module:

"""Generating CloudFormation template.""" 
 
from troposphere import ( 
    Base64, 
    ec2, 
    GetAtt, 
    Join, 
    Output, 
    Parameter, 
    Ref, 
    Template, 
) 

We are also going to define a first variable that will make editing the code easier for the remainder of the book as we will create new scripts building on this initial template:

ApplicationPort = "3000" 

From a code standpoint, the first thing we will do is initialize a Template variable. By the ...

Get Effective DevOps with AWS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.