# Buggy code
def update_hosted_zone_comment(
    Id=None,
    Name=None,
    Comment=None,
    PrivateZone=None,
    region=None,
    key=None,
    keyid=None,
    profile=None,
):
    """
    Update the comment on an existing Route 53 hosted zone.

    Id
        The unique Zone Identifier for the Hosted Zone.

    Name
        The domain name associated with the Hosted Zone(s).

    Comment
        Any comments you want to include about the hosted zone.

    PrivateZone
        Boolean - Set to True if changing a private hosted zone.

    CLI Example::

        salt myminion boto3_route53.update_hosted_zone_comment Name=example.org. \
                Comment="This is an example comment for an example zone"
    """
    if not _exactly_one((Id, Name)):
        raise SaltInvocationError("Exactly one of either Id or Name is required.")
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if Name:
        args = {
            "Name": Name,
            "PrivateZone": PrivateZone,
            "region": region,
            "key": key,
            "keyid": keyid,
            "profile": profile,
        }
        zone = find_hosted_zone(**args)
        if not zone:
            log.error(
                "Couldn't resolve domain name {0} to a hosted zone ID.".format(Name)
            )
            return []
        Id = zone[0]["HostedZone"]["Id"]
    tries = 10
    while tries:
        try:
            r = conn.update_hosted_zone_comment(Id=Id, Comment=Comment)
            r.pop("ResponseMetadata", None)
            return [r]
        except ClientError as e:
            if tries and e.response.get("Error", {}).get("Code") == "Throttling":
                log.debug("Throttled by AWS API.")
                time.sleep(3)
                retries -= 1
                continue
            log.error(
                "Failed to update comment on hosted zone {0}: {1}".format(
                    Name or Id, str(e)
                )
            )
    return []


# Traceback (UnboundLocalError)
----------
ID: Ensure r53 record set for testing.net exists
Function: boto3_route53.rr_present
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1837, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1794, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/boto3_route53.py", line 710, in rr_present
ChangeBatch=ChangeBatch, region=region, key=key, keyid=keyid, profile=profile):
File "/usr/lib/python2.7/dist-packages/salt/modules/boto3_route53.py", line 880, in change_resource_record_sets
retries -= 1
UnboundLocalError: local variable 'retries' referenced before assignment
Started: 18:51:15.675880
Duration: 1544688.487 ms
Changes:

Summary for mySaltMaster
------------
Succeeded: 0
Failed:    1
------------

# Fixed code
def update_hosted_zone_comment(
    Id=None,
    Name=None,
    Comment=None,
    PrivateZone=None,
    region=None,
    key=None,
    keyid=None,
    profile=None,
):
    """
    Update the comment on an existing Route 53 hosted zone.

    Id
        The unique Zone Identifier for the Hosted Zone.

    Name
        The domain name associated with the Hosted Zone(s).

    Comment
        Any comments you want to include about the hosted zone.

    PrivateZone
        Boolean - Set to True if changing a private hosted zone.

    CLI Example::

        salt myminion boto3_route53.update_hosted_zone_comment Name=example.org. \
                Comment="This is an example comment for an example zone"
    """
    if not _exactly_one((Id, Name)):
        raise SaltInvocationError("Exactly one of either Id or Name is required.")
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if Name:
        args = {
            "Name": Name,
            "PrivateZone": PrivateZone,
            "region": region,
            "key": key,
            "keyid": keyid,
            "profile": profile,
        }
        zone = find_hosted_zone(**args)
        if not zone:
            log.error(
                "Couldn't resolve domain name {0} to a hosted zone ID.".format(Name)
            )
            return []
        Id = zone[0]["HostedZone"]["Id"]
    tries = 10
    while tries:
        try:
            r = conn.update_hosted_zone_comment(Id=Id, Comment=Comment)
            r.pop("ResponseMetadata", None)
            return [r]
        except ClientError as e:
            if tries and e.response.get("Error", {}).get("Code") == "Throttling":
                log.debug("Throttled by AWS API.")
                time.sleep(3)
                tries -= 1
                continue
            log.error(
                "Failed to update comment on hosted zone {0}: {1}".format(
                    Name or Id, str(e)
                )
            )
    return []