Exemple #1
0
def lambda_fanout_clean(event, context):
    """Fanout SNS messages to cleanup snapshots when called by AWS Lambda."""

    # baseline logging for lambda
    utils.configure_logging(context, LOG)

    # for every region, send to this function
    clean.perform_fanout_all_regions(context)

    LOG.info('Function lambda_fanout_clean completed')
Exemple #2
0
def lambda_fanout_clean(event, context):
    """Fanout SNS messages to cleanup snapshots when called by AWS Lambda."""

    # baseline logging for lambda
    logging.basicConfig(level=logging.INFO)
    LOG.setLevel(logging.INFO)
    logging.getLogger('botocore').setLevel(logging.WARNING)
    logging.getLogger('boto3').setLevel(logging.WARNING)

    # for every region, send to this function
    clean.perform_fanout_all_regions(context)

    LOG.info('Function lambda_fanout_clean completed')
Exemple #3
0
def test_perform_fanout_all_regions_clean(mocker):
    """Test for method of the same name."""
    mocks.create_sns_topic('CleanSnapshotTopic')
    mocks.create_dynamodb()

    expected_regions = utils.get_regions()
    for r in expected_regions:  # must have an instance in the region to clean it
        mocks.create_instances(region=r)
    expected_sns_topic = utils.get_topic_arn('CleanSnapshotTopic', 'us-east-1')

    ctx = utils.MockContext()
    mocker.patch('ebs_snapper.clean.send_fanout_message')

    # fan out, and be sure we touched every region
    clean.perform_fanout_all_regions(ctx)
    for r in expected_regions:
        clean.send_fanout_message.assert_any_call(  # pylint: disable=E1103
            ctx,
            cli=False,
            region=r,
            topic_arn=expected_sns_topic)
Exemple #4
0
def shell_fanout_clean(*args):
    """Print fanout JSON messages, instead of sending them like lambda version."""
    # for every region, send to this function
    clean.perform_fanout_all_regions(CTX, cli=True)
    LOG.info('Function shell_fanout_clean completed')