Adding an ELB to our stack

We will go through the following changes. In the troposphere import section at the top of the script, we are going to import the subpackage elasticloadbalancing as follows:

from troposphere import ( 
    Base64,    ec2,
    GetAtt, 
    Join, 
    Output, 
    Parameter, 
    Ref, 
    Template, 
    elasticloadbalancing as elb, 
) 

The creation of an ELB requires specifying the VPC in which to add the load balancer. We can easily select the proper VPC by adding a new parameter to our template. To do so, right after the key pair parameter section, add a new parameter as follows:

t.add_parameter(Parameter( 
    "VpcId", 
    Type="AWS::EC2::VPC::Id", 
    Description="VPC" 
)) 

In addition to selecting which VPC to use to create the ELB, we can also select which subnets ...

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.