Skip to content

Commit

Permalink
Merge pull request #29 from remind101/vpc_internal_zone
Browse files Browse the repository at this point in the history
Add optional Internal Zone setup to VPC
  • Loading branch information
phobologic committed May 11, 2015
2 parents cec37b0 + 1bf030b commit 7ad4605
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion stacker/blueprints/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
This includes the VPC, it's subnets, availability zones, etc.
"""

from troposphere import Ref, Output, Join, FindInMap, Select, GetAZs
from troposphere import (
Ref, Output, Join, FindInMap, Select, GetAZs, Not, Equals
)
from troposphere import ec2
from troposphere.route53 import HostedZone, HostedZoneVPCs

from .base import Blueprint

Expand Down Expand Up @@ -60,6 +63,11 @@ class VPC(Blueprint):
"default": "NAT"},
}

def create_conditions(self):
self.template.add_condition(
"CreateInternalDomain",
Not(Equals(Ref("InternalDomain"), "")))

def create_vpc(self):
t = self.template
t.add_resource(ec2.VPC(
Expand All @@ -70,6 +78,17 @@ def create_vpc(self):
# Just about everything needs this, so storing it on the object
t.add_output(Output("VpcId", Value=VPC_ID))

def create_internal_zone(self):
t = self.template
t.add_resource(
HostedZone(
"EmpireInternalZone",
Name="empire",
VPCs=HostedZoneVPCs(
VPCId=Ref("VpcId"),
VPCRegion=Ref("AWS::Region")),
Condition="CreateInternalDomain"))

def create_default_security_group(self):
t = self.template
t.add_resource(ec2.SecurityGroup(
Expand Down Expand Up @@ -201,7 +220,9 @@ def create_nat_instance(self, zone_id, subnet_name):
return nat_instance

def create_template(self):
self.create_conditions()
self.create_vpc()
self.create_internal_zone()
self.create_default_security_group()
self.create_dhcp_options()
self.create_network()

0 comments on commit 7ad4605

Please sign in to comment.