项目作者: mattiashem

项目描述 :
Convert Bind to Route53 Cliudformations
高级语言: Python
项目地址: git://github.com/mattiashem/bindToRoute53.git
创建时间: 2019-10-15T11:27:00Z
项目社区:https://github.com/mattiashem/bindToRoute53

开源协议:

下载


bindToRoute53

Bind config into rouet53 cloudformations

We are moving our old bind server over to route53 and as we have all our config as code.
I needed to migrate our bind configs into route53 cloud templates.

So here is a small python script that reads the files in the folder recors. Then converts them into route 53 cloudformatins templates.

To do

  • The filename of the recors must be the same as the domain example hacking.robots.beer if the domain in hacking.robots.beer (I use the filename when a genereate)
  • You need to add txt and verify MX records :-)
  • Theer is a limit of 50 recors in every cloudformation template .. I hit that but check so you dont go over

To use

Req

  • Docker
  • Docker-compose

Use

Build the image

  1. docker-compose build

Add your bind file in the records folder (with correct name)

‘’’
docker-compose up
‘’’

This will generate the route53 cloudtemplates.

Is you get any errors verify that then name of the file is the same as the domain !

Output

This is my cmd output when building

  1. mahe@:~/projects/hrb/bindToRoute53$ docker-compose build
  2. Building bindtorouet53
  3. Step 1/10 : FROM python
  4. ---> 02d2bb146b3b
  5. Step 2/10 : EXPOSE 8080
  6. ---> Using cache
  7. ---> 0bae49565167
  8. Step 3/10 : RUN mkdir /code
  9. ---> Using cache
  10. ---> 25c452acb603
  11. Step 4/10 : COPY . /code/
  12. ---> 748de0c0acb3
  13. Step 5/10 : WORKDIR /code/code
  14. ---> Running in 78ba6d14b2e7
  15. Removing intermediate container 78ba6d14b2e7
  16. ---> 02c858a406ca
  17. Step 6/10 : RUN pip install --upgrade pip
  18. ---> Running in 69626ded3399
  19. Collecting pip
  20. Downloading https://files.pythonhosted.org/packages/4a/08/6ca123073af4ebc4c5488a5bc8a010ac57aa39ce4d3c8a931ad504de4185/pip-19.3-py2.py3-none-any.whl (1.4MB)
  21. Installing collected packages: pip
  22. Found existing installation: pip 19.2.3
  23. Uninstalling pip-19.2.3:
  24. Successfully uninstalled pip-19.2.3
  25. Successfully installed pip-19.3
  26. Removing intermediate container 69626ded3399
  27. ---> d27a971b31c7
  28. Step 7/10 : RUN pip3 install git+https://github.com/rthalley/dnspython
  29. ---> Running in ffe41cbd327e
  30. Collecting git+https://github.com/rthalley/dnspython
  31. Cloning https://github.com/rthalley/dnspython to /tmp/pip-req-build-gittsrh8
  32. Running command git clone -q https://github.com/rthalley/dnspython /tmp/pip-req-build-gittsrh8
  33. Building wheels for collected packages: dnspython
  34. Building wheel for dnspython (setup.py): started
  35. Building wheel for dnspython (setup.py): finished with status 'done'
  36. Created wheel for dnspython: filename=dnspython-2.0.0-py2.py3-none-any.whl size=185372 sha256=a0d13e5a72b5c837ebf0a5c2994120603c542a0cf3ec31c2a413cd8314178dc7
  37. Stored in directory: /tmp/pip-ephem-wheel-cache-ihr_ut_i/wheels/6b/57/51/8a22d863467edb8665f76580d84ac4e5ddfbd315f5fa1c4f7d
  38. Successfully built dnspython
  39. Installing collected packages: dnspython
  40. Successfully installed dnspython-2.0.0
  41. Removing intermediate container ffe41cbd327e
  42. ---> d29c07d9dd3e
  43. Step 8/10 : RUN pip3 install easyzone
  44. ---> Running in c97fc2f12fc1
  45. Collecting easyzone
  46. Downloading https://files.pythonhosted.org/packages/b0/1a/bf74b3267d641848ced5523c1422704790af7211e86aa765f6922b4e1c3a/easyzone-1.2.2.tar.gz
  47. Requirement already satisfied: dnspython in /usr/local/lib/python3.7/site-packages (from easyzone) (2.0.0)
  48. Building wheels for collected packages: easyzone
  49. Building wheel for easyzone (setup.py): started
  50. Building wheel for easyzone (setup.py): finished with status 'done'
  51. Created wheel for easyzone: filename=easyzone-1.2.2-cp37-none-any.whl size=7992 sha256=cdca0bcf42b6b66b2dd9cced5a0db511f43cb4e929d2942f6a8536913bd84a9d
  52. Stored in directory: /root/.cache/pip/wheels/b7/88/af/e6827feaee57713c87d6cb817a3da9b4ccf3dd59554c8b33ca
  53. Successfully built easyzone
  54. Installing collected packages: easyzone
  55. Successfully installed easyzone-1.2.2
  56. Removing intermediate container c97fc2f12fc1
  57. ---> f12078c49ccf
  58. Step 9/10 : RUN pip3 install pyyaml
  59. ---> Running in 8036d5c7872a
  60. Collecting pyyaml
  61. Downloading https://files.pythonhosted.org/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849582fe/PyYAML-5.1.2.tar.gz (265kB)
  62. Building wheels for collected packages: pyyaml
  63. Building wheel for pyyaml (setup.py): started
  64. Building wheel for pyyaml (setup.py): finished with status 'done'
  65. Created wheel for pyyaml: filename=PyYAML-5.1.2-cp37-cp37m-linux_x86_64.whl size=468686 sha256=998f6b37cf6da1dde4183a60486d6eaf332dce0c5e07730bb3e28d8516b39b01
  66. Stored in directory: /root/.cache/pip/wheels/d9/45/dd/65f0b38450c47cf7e5312883deb97d065e030c5cca0a365030
  67. Successfully built pyyaml
  68. Installing collected packages: pyyaml
  69. Successfully installed pyyaml-5.1.2
  70. Removing intermediate container 8036d5c7872a
  71. ---> 4c1842480db8
  72. Step 10/10 : CMD ["python","migrate.py"]
  73. ---> Running in 981e956422f0
  74. Removing intermediate container 981e956422f0
  75. ---> 66c9a2ecdb4d
  76. Successfully built 66c9a2ecdb4d
  77. Successfully tagged bindtoroute53_bindtorouet53:latest
  78. mahe@:~/projects/hrb/bindToRoute53$ docker-compose up
  79. Recreating bindtoroute53_bindtorouet53_1 ... done
  80. Attaching to bindtoroute53_bindtorouet53_1
  81. bindtoroute53_bindtorouet53_1 exited with code 0
  82. mahe:~/projects/hrb/bindToRoute53$ cat code/route53/hacking.robots.beer
  83. AWSTemplateFormatVersion: '2010-09-09'
  84. Resources:
  85. DNS:
  86. Properties:
  87. HostedZoneConfig:
  88. Comment: DNS Settings for hacking.robots.beer
  89. Name: hacking.robots.beer
  90. Type: AWS::Route53::HostedZone
  91. '@':
  92. DependsOn: DNS
  93. Properties:
  94. HostedZoneName: hacking.robots.beer.
  95. Name: '@'
  96. ResourceRecords:
  97. - dns
  98. TTL: 900
  99. Type: NS
  100. Type: AWS::Route53::RecordSet
  101. a_robot:
  102. DependsOn: DNS
  103. Properties:
  104. HostedZoneName: hacking.robots.beer.
  105. Name: a_robot
  106. ResourceRecords:
  107. - 127.0.0.1
  108. TTL: 900
  109. Type: A
  110. Type: AWS::Route53::RecordSet
  111. c_robot:
  112. DependsOn: DNS
  113. Properties:
  114. HostedZoneName: hacking.robots.beer.
  115. Name: c_robot
  116. ResourceRecords:
  117. - a_robot
  118. TTL: 900
  119. Type: CNAME
  120. Type: AWS::Route53::RecordSet