Creating a VPC with public and private subnets

We will create a new script in our EffectiveDevOpsTemplates repository and call it vpc-cf-template.py.

We will start with our usual boilerplates:

"""Generating CloudFormation template.""" 
 
from troposphere import ( 
    GetAZs, 
    Output, 
    Parameter, 
    Ref, 
    Select, 
    Sub, 
    Tags, 
    Template, 
    GetAtt 
) 
 
from troposphere.ec2 import ( 
    VPC, 
    InternetGateway, 
    NetworkAcl, 
    NetworkAclEntry, 
    Route, 
    RouteTable, 
    Subnet, 
    SubnetNetworkAclAssociation, 
    SubnetRouteTableAssociation, 
    VPCGatewayAttachment, 
    EIP, 
    NatGateway, 
) 
 
t = Template() 
 
t.add_description("Effective DevOps in AWS: VPC, public and private subnets") 

This template will require providing a parameter for the CIDR. We will create our subnets on the private (non-publicly ...

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.