Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Add a enable_internal_subnet config item which doesn't create internal
Browse files Browse the repository at this point in the history
subnets and NATs.

Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
  • Loading branch information
arjunrn committed Apr 8, 2020
1 parent 9254d49 commit 17a4a9d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sevenseconds/config/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ def configure_vpc(account: AccountData, region, base_ami_id):
if not account.dry_run:
subnet.delete()

enable_internal = account.config.get("enable_internal_subnets", True)
# Configure subnets
if vpc_config and 'subnets' in vpc_config:
subnets = custom_subnets(vpc_net, vpc_config['subnets'], availability_zones)
else:
subnets = default_subnets(vpc_net, availability_zones)
subnets = default_subnets(vpc_net, availability_zones, enable_internal)

for subnet in subnets:
configure_subnet(vpc, subnet, account.dry_run, ec2c.get_waiter('subnet_available'))

nat_instances = create_nat_instances(account, vpc, region)
if enable_internal:
nat_instances = create_nat_instances(account, vpc, region)
else:
nat_instances = {}
create_routing_tables(vpc, nat_instances,
account.options.get('re_add_defaultroute', False),
account.config.get('enable_dedicated_dmz_route', False))
Expand All @@ -110,8 +114,11 @@ def custom_subnets(vpc_net, subnet_config, availability_zones):
yield Subnet(az, subnet['type'], cidr, subnet.get('tags', {}))


def default_subnets(vpc_net, availability_zones):
for subnet_type in 'dmz', 'internal':
def default_subnets(vpc_net, availability_zones, enable_internal: bool):
subnet_types = ['dmz']
if enable_internal:
subnet_types.append('internal')
for subnet_type in subnet_types:
for i, az in enumerate(sorted(availability_zones)):
tags = {}
if subnet_type == 'dmz':
Expand Down

0 comments on commit 17a4a9d

Please sign in to comment.