def sns(event, context):
    """
    Send an SNS message
    :param event: Lambda event
    :param context: Lambda context
    :return: None
    """
    cli = get_sns_client()

    logger.info("Publishing message for event: %s" % event)
    cli.publish(TopicArn=topic_arn(), Message=build_message(event))
def sns_conditional(event, context):
    """Send an SNS message if 'serviceError' is specified in the input.
    :param event: Lambda event
    :param context: Lambda context
    :return: True if a message was sent, False otherwise
    """

    cli = get_sns_client()

    error = event.get("serviceError")
    if error:
        logger.info("Publishing message for event %s" % event)
        cli.publish(TopicArn=topic_arn(), Message=build_message(event))
        return True

    logger.info("No message to publish for event %s" % event)
    return False
Exemplo n.º 3
0
def test_forecast_getter():
    cli = get_sns_client()
    assert "https://sns.us-east-1.amazonaws.com" in cli.meta.endpoint_url