Skip to content

Commit

Permalink
Merge pull request #39 from remind101/fix_internal_zone_check
Browse files Browse the repository at this point in the history
Fix internal zone detection
  • Loading branch information
phobologic committed Jul 14, 2015
2 parents 58c68be + c7b6d42 commit 9a73068
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

tests_require = [
'nose>=1.0',
'mock>=1.0',
'mock==1.0.1',
]


Expand Down
26 changes: 15 additions & 11 deletions stacker/blueprints/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""

from troposphere import (
Ref, Output, Join, FindInMap, Select, GetAZs, Not, Equals, Tags, And, Or
Ref, Output, Join, FindInMap, Select, GetAZs, Not, Equals, Tags, Or,
Condition
)
from troposphere import ec2
from troposphere.route53 import HostedZone, HostedZoneVPCs
Expand Down Expand Up @@ -65,17 +66,20 @@ class VPC(Blueprint):

def create_conditions(self):
self.template.add_condition(
"NoHostedZones",
And(
Equals(Ref("InternalDomain"), ""),
Equals(Ref("BaseDomain"), ""),
))
"HasInternalDomain",
Not(Equals(Ref("InternalDomain"), "")))
self.template.add_condition(
"HasExternalDomain",
Not(Equals(Ref("BaseDomain"), "")))
self.template.add_condition(
"HasHostedZones",
Or(
Not(Equals(Ref("InternalDomain"), "")),
Not(Equals(Ref("BaseDomain"), "")),
Condition("HasInternalDomain"),
Condition("HasExternalDomain")
))
self.template.add_condition(
"NoHostedZones",
Not(Condition("HasHostedZones")))

def create_vpc(self):
t = self.template
Expand All @@ -96,17 +100,17 @@ def create_internal_zone(self):
VPCs=[HostedZoneVPCs(
VPCId=VPC_ID,
VPCRegion=Ref("AWS::Region"))],
Condition="HasHostedZones"))
Condition="HasInternalDomain"))
t.add_output(
Output(
"InternalZoneId",
Value=Ref("InternalZone"),
Condition="HasHostedZones"))
Condition="HasInternalDomain"))
t.add_output(
Output(
"InternalZoneName",
Value=Ref("InternalDomain"),
Condition="HasHostedZones"))
Condition="HasInternalDomain"))

def create_default_security_group(self):
t = self.template
Expand Down

0 comments on commit 9a73068

Please sign in to comment.