0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Route 53のレコードをタブ区切りで出力するワンライナー

Posted at

必要になったので書きました。必要なものはAWS CLI v2jq v1.6です。

aws route53 list-resource-record-sets --hosted-zone-id ZXXXXXXXXXXXX | \
  jq '.ResourceRecordSets [] | if has("ResourceRecords") then [.Name, .Type, .TTL, ([.ResourceRecords[] .Value] | join(","))] else [.Name, .Type, -1, (.AliasTarget .DNSName)] end | @tsv' -r

1レコードに複数の値があるもの(TXTレコードとかMXレコードとか)はカンマ区切りで横に並びます。

出力例

example.com.	MX	3600	1 aspmx.l.google.com,5 alt1.aspmx.l.google.com,5 alt2.aspmx.l.google.com,10 aspmx2.googlemail.com,10 aspmx3.googlemail.com
example.com.	NS	172800	ns-1411.awsdns-99.org.,ns-999.awsdns-99.net.,ns-9999.awsdns-99.co.uk.,ns-999.awsdns-99.com.
dev1.example.com.	A	300	203.0.113.1
dev2.example.com.	A	-1	dualstack.alb-name-999999999.ap-northeast-1.elb.amazonaws.com.

対応できないレコードなどありましたらご指摘ください。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?