@@ -131,7 +131,7 @@ func (c *route53Client) deploy(name string, t *dnsdisc.Tree) error {
131131 }
132132 }
133133
134- // wait for all change batches to propagate
134+ // Wait for all change batches to propagate.
135135 for _ , change := range changesToCheck {
136136 log .Info (fmt .Sprintf ("Waiting for change request %s" , * change .ChangeInfo .Id ))
137137 wreq := & route53.GetChangeInput {Id : change .ChangeInfo .Id }
@@ -196,24 +196,29 @@ func (c *route53Client) computeChanges(name string, records map[string]string, e
196196 records = lrecords
197197
198198 var changes []types.Change
199- for path , val := range records {
199+ for path , newValue := range records {
200+ prevRecords , exists := existing [path ]
201+ prevValue := strings .Join (prevRecords .values , "" )
202+
203+ // prevValue contains quoted strings, encode newValue to compare.
204+ newValue = splitTXT (newValue )
205+
206+ // Assign TTL.
200207 ttl := int64 (rootTTL )
201208 if path != name {
202209 ttl = int64 (treeNodeTTL )
203210 }
204211
205- prevRecords , exists := existing [path ]
206- prevValue := strings .Join (prevRecords .values , "" )
207212 if ! exists {
208213 // Entry is unknown, push a new one
209- log .Info (fmt .Sprintf ("Creating %s = %q " , path , val ))
210- changes = append (changes , newTXTChange ("CREATE" , path , ttl , splitTXT ( val ) ))
211- } else if prevValue != val || prevRecords .ttl != ttl {
214+ log .Info (fmt .Sprintf ("Creating %s = %s " , path , newValue ))
215+ changes = append (changes , newTXTChange ("CREATE" , path , ttl , newValue ))
216+ } else if prevValue != newValue || prevRecords .ttl != ttl {
212217 // Entry already exists, only change its content.
213- log .Info (fmt .Sprintf ("Updating %s from %q to %q " , path , prevValue , val ))
214- changes = append (changes , newTXTChange ("UPSERT" , path , ttl , splitTXT ( val ) ))
218+ log .Info (fmt .Sprintf ("Updating %s from %s to %s " , path , prevValue , newValue ))
219+ changes = append (changes , newTXTChange ("UPSERT" , path , ttl , newValue ))
215220 } else {
216- log .Info (fmt .Sprintf ("Skipping %s = %q " , path , val ))
221+ log .Debug (fmt .Sprintf ("Skipping %s = %s " , path , newValue ))
217222 }
218223 }
219224
@@ -288,21 +293,19 @@ func changeCount(ch types.Change) int {
288293
289294// collectRecords collects all TXT records below the given name.
290295func (c * route53Client ) collectRecords (name string ) (map [string ]recordSet , error ) {
291- log .Info (fmt .Sprintf ("Retrieving existing TXT records on %s (%s)" , name , c .zoneID ))
292296 var req route53.ListResourceRecordSetsInput
293297 req .HostedZoneId = & c .zoneID
294298 existing := make (map [string ]recordSet )
295- for {
299+ for page := 0 ; ; page ++ {
300+ log .Info ("Loading existing TXT records" , "name" , name , "zone" , c .zoneID , "page" , page )
296301 resp , err := c .api .ListResourceRecordSets (context .TODO (), & req )
297302 if err != nil {
298303 return existing , err
299304 }
300-
301305 for _ , set := range resp .ResourceRecordSets {
302306 if ! isSubdomain (* set .Name , name ) || set .Type != types .RRTypeTxt {
303307 continue
304308 }
305-
306309 s := recordSet {ttl : * set .TTL }
307310 for _ , rec := range set .ResourceRecords {
308311 s .values = append (s .values , * rec .Value )
@@ -314,14 +317,12 @@ func (c *route53Client) collectRecords(name string) (map[string]recordSet, error
314317 if ! resp .IsTruncated {
315318 break
316319 }
317-
318- // Set the cursor to the next batc. From the AWS docs:
320+ // Set the cursor to the next batch. From the AWS docs:
319321 //
320322 // To display the next page of results, get the values of NextRecordName,
321323 // NextRecordType, and NextRecordIdentifier (if any) from the response. Then submit
322324 // another ListResourceRecordSets request, and specify those values for
323325 // StartRecordName, StartRecordType, and StartRecordIdentifier.
324-
325326 req .StartRecordIdentifier = resp .NextRecordIdentifier
326327 req .StartRecordName = resp .NextRecordName
327328 req .StartRecordType = resp .NextRecordType
0 commit comments