import re


def _parse_arn(arn):
    """
    ec2)  arn:aws:ec2:<REGION>:<ACCOUNT_ID>:instance/<instance-id>

    arn:partition:service:region:account-id:resource-id
    arn:partition:service:region:account-id:resource-type/resource-id
    arn:partition:service:region:account-id:resource-type:resource-id

    Returns: resource_list, [regions]
    """
    p = (r"(?P<arn>arn):"
         r"(?P<partition>aws|aws-cn|aws-us-gov):"
         r"(?P<service>[A-Za-z0-9_\-]*):"
         r"(?P<region>[A-Za-z0-9_\-]*):"
         r"(?P<account>[A-Za-z0-9_\-]*):"
         r"(?P<resources>[A-Za-z0-9_\-:/]*)")
    r = re.compile(p)
    match = r.match(arn)
    if match:
        d = match.groupdict()
    else:
        return (None, None)
    region = d.get('region', None)
    resource_id = None
    resources = d.get('resources', None)
    if resources:
        items = re.split('/|:', resources)
        if len(items) == 1:
            resource_id = items[0]
        elif len(items) == 2:
            resource_type = items[0]
            resource_id = items[1]
        else:
            print(f'ERROR parsing: {resources}')
    return [resource_id], [region]