Skip to content

Instantly share code, notes, and snippets.

@paulonteri
Last active January 10, 2022 06:28
Show Gist options
  • Save paulonteri/5af4fff4d36eaebe9ed21bcae77d0f90 to your computer and use it in GitHub Desktop.
Save paulonteri/5af4fff4d36eaebe9ed21bcae77d0f90 to your computer and use it in GitHub Desktop.
Used to transer from Google Cloud DNS to Cloudflare DNS. This is after exporting the Google Cloud DNS config to a yaml file.
import yaml
with open("records.yaml", "r") as stream:
with open('cloudflare.txt', 'w+') as cloudflare_file:
docs = yaml.load_all(stream)
for doc in docs:
item = dict(doc.items())
for rrdata in item["rrdatas"]:
cloudflare_file.write(
f"{item['name']} 1 IN {item['type']} {rrdata} \n"
)
example.com. 1 IN A 78.78.21.21
example.com. 1 IN MX 10 mx.mailserver.com.
example.com. 1 IN MX 20 mx2.mailserver.com.
example.com. 1 IN MX 50 mx3.mailserver.com.
example.com. 1 IN NS ns-cloud-e1.purpledomains.com.
example.com. 1 IN NS ns-cloud-e2.purpledomains.com.
example.com. 1 IN NS ns-cloud-e3.purpledomains.com.
example.com. 1 IN NS ns-cloud-e4.purpledomains.com.
api.example.com. 1 IN CNAME ghs.purplehosted.com.
dsa.example.com. 1 IN A 199.38.158.100
ecommerce.example.com. 1 IN A 218.239.32.21
ecommerce.example.com. 1 IN A 218.239.34.21
ecommerce.example.com. 1 IN A 218.239.38.21
ecommerce.example.com. 1 IN A 218.239.38.21
ecommerce.example.com. 1 IN AAAA 2001:4880:4802:32::15
ecommerce.example.com. 1 IN AAAA 2001:4880:4802:34::15
ecommerce.example.com. 1 IN AAAA 2001:4880:4802:38::15
ecommerce.example.com. 1 IN AAAA 2001:4880:4802:38::15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment