Group By Endpoint names per Hosted Zone on AWS

This commit is contained in:
Leonardo Quatrocchi 2024-03-03 16:36:32 -03:00
parent e55200ae74
commit 7c7a1c30ef

View File

@ -995,12 +995,12 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change
}
for _, z := range zones {
// Initialize the map for the Current Zone & Record Type if it doesn't exist
if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] == nil {
visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] = make(map[string]bool)
if visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type] == nil {
visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type] = make(map[string]bool)
}
if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] {
log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type)
if visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type][hostname] {
log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type)
continue
}
@ -1019,8 +1019,8 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change
}
}
changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c)
visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] = true
log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type)
visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type][hostname] = true
log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type)
}
}