Skip to content

Commit

Permalink
auto detect domain
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Apr 9, 2015
1 parent 2b54c7e commit 8ce53e3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion senza/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import boto.vpc
import boto.ec2
import boto.iam
import boto.route53

CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])

Expand Down Expand Up @@ -456,13 +457,28 @@ def component_load_balancer(definition, configuration, args, info):
return definition


def component_weighted_dns_load_balancer(definition, configuration, args, info):
if 'Domains' not in configuration:
dns_conn = boto.route53.connect_to_region(args.region)
zones = dns_conn.get_zones()
domains = sorted([zone.name.rstrip('.') for zone in zones])
version_subdomain = '{}-{}'.format(info['StackName'], info['StackVersion'])
configuration['Domains'] = {'MainDomain': {'Type': 'weighted',
'Zone': domains[0],
'Subdomain': info['StackName']},
'VersionDomain': {'Type': 'standalone',
'Zone': domains[0],
'Subdomain': version_subdomain}}
return component_load_balancer(definition, configuration, args, info)


COMPONENTS = {
"Senza::Configuration": component_basic_configuration,
"Senza::StupsAutoConfiguration": component_stups_auto_configuration,
"Senza::AutoScalingGroup": component_auto_scaling_group,
"Senza::TaupageAutoScalingGroup": component_taupage_auto_scaling_group,
"Senza::ElasticLoadBalancer": component_load_balancer,
"Senza::WeightedDnsElasticLoadBalancer": component_load_balancer,
"Senza::WeightedDnsElasticLoadBalancer": component_weighted_dns_load_balancer,
}

BASE_TEMPLATE = {
Expand Down

0 comments on commit 8ce53e3

Please sign in to comment.