def checkstackstatus()

in buildstack.py [0:0]


def checkstackstatus(region):
# checks stack building status    
    try:
        
        stack_building = True

        client = boto3.client('cloudformation',region_name=region)

        event_list = client.describe_stack_events(StackName=stackname).get("StackEvents")
        stack_event = event_list[0]

        if (stack_event.get('ResourceType') == 'AWS::CloudFormation::Stack' and stack_event.get('ResourceStatus') == 'CREATE_COMPLETE'):
            stack_building = False
            print("Stack construction completed for region...", region)
        elif (stack_event.get('ResourceType') == 'AWS::CloudFormation::Stack' and stack_event.get('ResourceStatus') == 'ROLLBACK_COMPLETE'):
            stack_building = False
            print("Stack construction failed for region...", region)
            sys.exit(1)
        else:
            print("Stack creation in progress for region...", region)

        return stack_building

    except ClientError as e:
        print("[ERROR]",e)
        raise
    except Exception as e:
        print("[ERROR]", e)