Skip to main content

A convenient Python interface to AWS route53 on top of Boto

Project description

zone53 is a convenient Python API to manage Amazon’s DNS web service route53. Essentially, it is a thin layer on top of boto.route53 providing Zone and Record classes.

Examples:

from zone53 import Zone, Record

# creating new zone example.com.
zone = Zone.create('example.com')

# getting all available zones as a list
zones = Zone.get_all()

# getting an existing zone by name
zone = Zone.get('example.com')

# constructing a FQDN for a name
zone.fqdn('test') == 'test.example.com.'

# fetching all records
records = zone.get_records()

# fetching CNAME records with ttl=300
cnames = zone.get_records( type='CNAME', ttl=300 )

# fetching A records for test.example.com. (using incomplete name)
empty = zone.get_records( type='A', name='test' )

# fetching nameservers
ns_records = zone.get_records( type='NS' )
nameservers = ns_records and ns_records[0].value or []

# adding a CNAME record with ttl=60
# (note, you can use incomplete names when passing zone as a kw-argument)
rec = Record( type='CNAME', name='www', value='', ttl=60, zone=zone )
status = rec.add()  # same as zone.add_record( rec )

# adding three A records
Record( name='node01.example.com', value='192.168.1.1' ).add( zone )
Record( name='node02.example.com', value='192.168.1.2' ).add( zone )
Record( name='node03.example.com', value='192.168.1.3' ).add( zone )

# adding a weighted CNAME record set (WRR)
r1 = Record( type='CNAME', name='node', value='node01', weight=2, id='node01', zone=zone )
r2 = Record( type='CNAME', name='node', value='node02', weight=2, id='node02', zone=zone )
r3 = Record( type='CNAME', name='node', value='node03', weight=2, id='node03', zone=zone )
zone.add_record( r1 )  # same as r1.add()
zone.add_record( r2 )  # same as r2.add()
zone.add_record( r3 )  # same as r3.add()

# updaing a record
r1.update( id='heavy-node', weight=5 )

# deleting a record
r2.delete()

# deleting a zone
for rec in zone.get_records( type='CNAME' ): rec.delete()
for rec in zone.get_records( type='A' ):     rec.delete()
zone.delete()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zone53-0.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page