AWS 에서, ELB 나 클라우드프론트 등 제공되는 서비스의 영역에서,
고정된 EIP가 아닌 경우 해당 호스트에 매핑되어 있는, 아이피 정보는 생각보다 빈번하게 변경됩니다.
관련하여, 아래와 같이 보유중인 호스트존 정보를 읽고, 해당 레코드 타입의 도메인의 아이피를 업데이트 할 수 있는 방법을 정리합니다.
해당 스크립트는 awscli를 이용합니다.
코드 관련 에디터툴을 적절한 것을 아직 찾지 못해 보기가 불편한점 양해부탁드립니다. ^^;;;
#!/bin/bash
# SCL python27 project enable source /opt/rh/python27/enable
#qury all HOSTZONEID ZONEIDS=`aws –profile dnsview route53 list-hosted-zones-by-name –query “HostedZones[].Id” –output text`
for ZONEID in ${ZONEIDS[@]} do if [ “$ZONEID” != “/hostedzone/Z2NKR4123123123” ]; then #============ QUERY FOR ALL HOSTZONE ID in OUR ACCOUNT =================== #A record domain query afqdn=`aws –profile dnsview route53 list-resource-record-sets –hosted-zone-id ${ZONEID} –output text –query “ResourceRecordSets[?Type==’A’].Name”` for domain in ${afqdn[@]} do ips=`dig +short $domain`; echo -e “$domain \t(Type A)”; for ip in ${ips[@]} do echo -e “\t$ip”; done done #CNAME record domain query cfqdn=`aws –profile dnsview route53 list-resource-record-sets –hosted-zone-id ${ZONEID} –output text –query “ResourceRecordSets[?Type==’CNAME’].Name”` # Unset Variable unset domain; unset ips; unset ip; for domain in ${cfqdn[@]} do ips=`dig +short $domain`; echo -e “$domain \t(Type CNAME)”; for ip in ${ips[@]} do echo -e “\t$ip”; done done #============ QUERY FOR ALL HOSTZONE ID in OUR ACCOUNT =================== else echo -e “\n”; fi done |