in github-runner-ami/packer/files/runner-supervisor.py [0:0]
def get_lifecycle_state() -> str:
    global INSTANCE_ID, OWN_ASG
    if not INSTANCE_ID:
        with open('/var/lib/cloud/data/instance-id') as fh:
            INSTANCE_ID = fh.readline().strip()
    asg_client = boto3.client('autoscaling')
    try:
        instances = asg_client.describe_auto_scaling_instances(
            InstanceIds=[INSTANCE_ID],
        )['AutoScalingInstances']
    except asg_client.exceptions.ClientError:
        return "UNKNOWN"
    if len(instances) != 1:
        return "UNKNOWN"
    details = instances[0]
    if not OWN_ASG:
        OWN_ASG = details['AutoScalingGroupName']
    return details['LifecycleState']