def cleanup_stacks(conn, regexp_stack_list, interactive=True):
    """
        cleanup_stacks main function

        conn: AWS connection
        regexp_stack_list: List list regex to be compared to the stack names.
        interactive: Interactive mode, ask user before delete the stacks
    """

    logger.info("Stacks to delete:")
    stack_list = get_safe_stack_list(conn, regexp_stack_list)
    for s in stack_list:
        logger.info(s.stack_name)
    # delete the stacks matched
    confirmation_message = "Do you agree to delete those %d stacks?" % len(stack_list)
    if not interactive or get_confirmation(confirmation_message):
        for stack in stack_list:
            logger.info("deleting stack %s...", stack.stack_name)
            conn.delete_stack(stack.stack_name)
Exemple #2
0
 def test_get_confirmation_possitive(self, mock):
     self.assertTrue(get_confirmation('Test confirmation'))
     mock.assert_called_once()
     self.assertEqual(3, mock.call_count)
     mock.reset_mock()