cloudformation/lambda_backup.py [85:124]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            response_iterator_status = response_iterator['CommandInvocations'][0]['Status']
            if response_iterator_status != 'Pending':
                if response_iterator_status == 'InProgress' or response_iterator_status == 'Success':
                    logging.info( "Status: %s", response_iterator_status)
                    return True
                else:
                    logging.error("ERROR: status: %s", response_iterator)
                    return False
        time.sleep(timewait)
        timewait += timewait

def abandon_lifecycle(life_cycle_hook, auto_scaling_group, instance_id):
    asg_client = boto3.client('autoscaling')
    try:
        response = asg_client.complete_lifecycle_action(
            LifecycleHookName=life_cycle_hook,
            AutoScalingGroupName=auto_scaling_group,
            LifecycleActionResult='ABANDON',
            InstanceId=instance_id
            )
        if check_response(response):
            logger.info("Lifecycle hook abandoned correctly: %s", response)
        else:
            logger.error("Lifecycle hook could not be abandoned: %s", response)
    except Exception, e:
        logger.error("Lifecycle hook abandon could not be executed: %s", str(e))
        return None

def lambda_handler(event, context):
    try:
        logger.info(json.dumps(event))
        message = event['detail']
        if LIFECYCLE_KEY in message and ASG_KEY in message:
            life_cycle_hook = message[LIFECYCLE_KEY]
            auto_scaling_group = message[ASG_KEY]
            instance_id = message[EC2_KEY]
            if check_document():
                command_id = send_command(instance_id)
                if command_id != None:
                    if check_command(command_id, instance_id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



lambda_backup.py [85:124]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              response_iterator_status = response_iterator['CommandInvocations'][0]['Status']
              if response_iterator_status != 'Pending':
                  if response_iterator_status == 'InProgress' or response_iterator_status == 'Success':
                      logging.info( "Status: %s", response_iterator_status)
                      return True
                  else:
                      logging.error("ERROR: status: %s", response_iterator)
                      return False
        time.sleep(timewait)
        timewait += timewait

def abandon_lifecycle(life_cycle_hook, auto_scaling_group, instance_id):
    asg_client = boto3.client('autoscaling')
    try:
        response = asg_client.complete_lifecycle_action(
            LifecycleHookName=life_cycle_hook,
            AutoScalingGroupName=auto_scaling_group,
            LifecycleActionResult='ABANDON',
            InstanceId=instance_id
            )
        if check_response(response):
            logger.info("Lifecycle hook abandoned correctly: %s", response)
        else:
            logger.error("Lifecycle hook could not be abandoned: %s", response)
    except Exception, e:
        logger.error("Lifecycle hook abandon could not be executed: %s", str(e))
        return None    

def lambda_handler(event, context):
    try:
        logger.info(json.dumps(event))
        message = event['detail']
        if LIFECYCLE_KEY in message and ASG_KEY in message:
            life_cycle_hook = message[LIFECYCLE_KEY]
            auto_scaling_group = message[ASG_KEY]
            instance_id = message[EC2_KEY]
            if check_document():
                command_id = send_command(instance_id)
                if command_id != None:
                    if check_command(command_id, instance_id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



