def add_hosted_zone_id_for_alias_target_if_missing(self, rs):
        """Add proper hosted zone id to record set alias target if missing."""
        alias_target = getattr(rs, "AliasTarget", None)
        if alias_target:
            hosted_zone_id = getattr(alias_target, "HostedZoneId", None)
            if not hosted_zone_id:
                dns_name = alias_target.DNSName
                if dns_name.endswith(CF_DOMAIN):
                    alias_target.HostedZoneId = CLOUDFRONT_ZONE_ID
                elif dns_name.endswith(ELB_DOMAIN):
                    region = dns_name.split('.')[-5]
                    alias_target.HostedZoneId = ELB_ZONE_IDS[region]
                elif dns_name in S3_WEBSITE_ZONE_IDS:
                    alias_target.HostedZoneId = S3_WEBSITE_ZONE_IDS[dns_name]
                else:
                    alias_target.HostedZoneId = self.hosted_zone_id
        return rs
Add proper hosted zone id to record set alias target if missing.