File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616./route53-wildcard.py create mycluster.gabrtv.io deis-elb.blah.amazonaws.com
1717./route53-wildcard.py delete mycluster.gabrtv.io deis-elb.blah.amazonaws.com
1818"""
19+
20+ from __future__ import print_function
21+
1922import boto .route53
2023import docopt
21- import json
22- import subprocess
24+ import socket
2325import time
26+ import uuid
2427
2528
2629def parse_args ():
2730 return docopt .docopt (__doc__ )
2831
32+
2933def create_cname (args ):
3034 conn = boto .route53 .connect_to_region (args ['--region' ])
3135 zone = conn .get_zone (args ['<zone>' ])
32- status = zone .add_cname (args ['<name>' ], args ['<value>' ], ttl = args ['--ttl' ])
36+ name = args ['<name>' ]
37+ status = zone .add_cname (name , args ['<value>' ], ttl = args ['--ttl' ])
3338 print ("waiting for record to sync: {}" .format (status ))
3439 while status .update () != "INSYNC" :
3540 time .sleep (2 )
3641 print (status )
42+ print ('waiting for wildcard domain to become available...' , end = '' )
43+ # AWS docs say it can take up to 30 minutes for route53 changes to happen, although
44+ # it seems to be almost immediate.
45+ for i in xrange (120 ):
46+ try :
47+ random_hostname = str (uuid .uuid4 ())[:8 ]
48+ if socket .gethostbyname ("{}.{}" .format (random_hostname , name )):
49+ print ('ok' )
50+ break
51+ except socket .gaierror :
52+ time .sleep (15 )
53+
3754
3855def delete_cname (args , block = False ):
3956 conn = boto .route53 .connect_to_region (args ['--region' ])
You can’t perform that action at this time.
0 commit comments