Ejemplo n.º 1
0
def lambda_handler(event, context):
    if "manage" in event:
        output = io.StringIO()
        management.call_command(*event["manage"].split(" "), stdout=output)
        return {"output": output.getvalue()}
    else:
        return awsgi.response(application, event, context)
Ejemplo n.º 2
0
def lambda_handler(event, context):
    return awsgi.response(
        application,
        event,
        context,
        base64_content_types={"image/png", "image/jpeg", "image/x-icon"},
    )
Ejemplo n.º 3
0
def lambda_handler(event, context):
    logger.info("Event: {}".format(event))
    return awsgi.response(app, event, context, base64_content_types={
        "image/png",
        "image/x-icon",
        # Inside the Lambda container Flask uses an alternative content type for "favicon.ico"
        "image/vnd.microsoft.icon",
    })
Ejemplo n.º 4
0
def handler(event, context):
    """
    Lambda Handler. wrap the event and context into WSGI application
        using awsgi. Using the werkzeug tools set to contruct a
        response.
        awsgi --> https://github.com/slank/awsgi.git
    """
    return awsgi.response(WSGIApp(), event, context)
Ejemplo n.º 5
0
def handle(event, context):
    try:
        logger.info("handling event", subhub_event=event, context=context)
        return awsgi.response(app, event, context)
    except Exception as e:  # pylint: disable=broad-except
        logger.exception("exception occurred", subhub_event=event, context=context, error=e)
        # TODO: Add Sentry exception catch here
        raise
Ejemplo n.º 6
0
def lambda_handler(event, context):
    response = awsgi.response(app, event, context)
    response["isBase64Encoded"] = False
    cors_header = {
        "X-Requested-With": '*',
        "Access-Control-Allow-Headers": 'Content-Type,X-Amz-Date,Authorization,X-Api-Key,x-requested-with',
        "Access-Control-Allow-Origin": '*',
        "Access-Control-Allow-Methods": 'POST,GET,OPTIONS'
    }

    response["headers"] = cors_header
    return response
Ejemplo n.º 7
0
def handler(event: Dict[str, Any], context: object) -> Any:
    domain_id = (event.get("requestContext", {}).get("authorizer",
                                                     {}).get("domainId", None))
    if domain_id is not None:
        event.get("headers")["x-tenant-id"] = domain_id

    app = create_app()
    base64_types = ["image/png"]
    return awsgi.response(app,
                          event,
                          context,
                          base64_content_types=base64_types)
Ejemplo n.º 8
0
def lambda_handler(event, context):
    """
    AWS lambda insertion point.

    :param event: AWS Lambda event data
    :param context: AWS Lambda context
    :return: Service response
    """
    aws_lambda_logging.setup(level='INFO', boto_level='INFO')
    LOGGER.info(f'Micro Airlines API {__version__}')
    LOGGER.info({'event': event})
    return awsgi.response(app, event, context)
Ejemplo n.º 9
0
def handle(event, context):  # noqa
    if 'headers' in event and isinstance(event['headers'], dict):

        # Cloudfront isn't configured to pass Host headers, so the provided Host
        # header is the API Gateway hostname
        if 'SERVER_NAME' in os.environ:
            event['headers']['Host'] = os.environ['SERVER_NAME']
        # Cloudfront drops X-Forwarded-Proto, so the value provided is from API
        # Gateway
        event['headers']['X-Forwarded-Proto'] = 'https'

    return awsgi.response(app, event, context)
Ejemplo n.º 10
0
def handle(event, context):
    # Cloudfront isn't configured to pass Host headers, so the provided Host
    # header is the API Gateway hostname
    # event['headers']['Host'] = os.environ['SERVER_NAME']
    event['headers']['X-Stage'] = event['requestContext']['stage']

    signal.setitimer(signal.ITIMER_REAL,
                     (context.get_remaining_time_in_millis() - 250) / 1000)
    try:
        return awsgi.response(app, event, context)
    finally:
        # clear the interval timer
        signal.setitimer(signal.ITIMER_REAL, 0)
Ejemplo n.º 11
0
def run(event, context):
    flask_app = Flask(__name__)
    initialize_app(flask_app)

    debug_env = os.environ.get("DEBUG", 'false')
    debug = debug_env.lower() == 'true'

    if (debug):
        print(event)

    return awsgi.response(flask_app,
                          event,
                          context,
                          base64_content_types={"image/png"})
Ejemplo n.º 12
0
def lambda_handler(evt, ctx):
    """AWS Lambda entrypoint"""

    try:
        return awsgi.response(app, evt, ctx)
    except Exception as err:
        print(f'{err}')

        return {
            'statusCode': 500,
            'body': json.dumps({
                'message': 'internal server error',
            })
        }
Ejemplo n.º 13
0
def handler(event, context):
    """
    Provides support for AWS Lambda
    """
    config_name = os.environ.get("config_name", "ebr_board_config")
    vault_config_name = os.environ.get("vault_config_name",
                                       "ebr_board_vault_config")
    vault_creds_name = os.environ.get("vault_creds_name",
                                      "ebr_board_vault_creds")
    config_format = os.environ.get("config_format", "yaml")

    store = EC2ParameterStore()
    config = store.get_parameters(
        [config_name, vault_config_name, vault_creds_name], decrypt=True)

    app = create_app(
        config=config[config_name],
        vault_config=config[vault_config_name],
        vault_creds=config[vault_creds_name],
        config_format=config_format,
    )
    return awsgi.response(app, event, context)
Ejemplo n.º 14
0
def handler(event, context):
  """
  The Lambda handler entry point
  """

  log = ContextLog.get_logger('handler', True)
  log.setLevel(os.environ.get('LOG_LEVEL', 'DEBUG'))

  ContextLog.put_start_time()
  ContextLog.put_request_id(context.aws_request_id)

  log.info('Request: start - event %s', json.dumps(event))

  try:
    log.info('Request: running')

    return awsgi.response(app, event, context)

  except:
    log.exception('Unexpected exception')
    raise
  finally:
    ContextLog.put_end_time()
    log.info('Request: end')
Ejemplo n.º 15
0
def handler(event, context):
    print(event)
    print(context)

    return awsgi.response(app, event, context)
Ejemplo n.º 16
0
def lambda_handler(event, context):
    """This links lambda execution up to our WSGI app."""
    return awsgi.response(app, event, context)
Ejemplo n.º 17
0
def lambda_handler(event, context):
    print("Lambda event", event)
    return awsgi.response(create_app(), event, context, base64_content_types={"application/octet-stream"})
Ejemplo n.º 18
0
def lambda_handler(event, context):
    print('Event {}'.format(json.dumps(event)))
    my_app = create_app(os.getenv('APP_ENV') or 'dev')
    return awsgi.response(my_app, event, context)
Ejemplo n.º 19
0
def handler(event, context):
    return awsgi.response(server,
                          event,
                          context,
                          base64_content_types={"image/png"})
Ejemplo n.º 20
0
def lambda_handler(event, context):
    response = awsgi.response(app, event, context)
    response["statusCode"] = int(response["statusCode"])
    return response
Ejemplo n.º 21
0
def handle(event, context):
    try:
        return awsgi.response(app, event, context)
    except Exception:  # pylint: disable=broad-except
        logger.exception("Exception occurred while handling %s", event)
Ejemplo n.º 22
0
def lambda_handler(event, context):
    return awsgi.response(APP,
                          event,
                          context,
                          base64_content_types=BASE64_CONTENT_TYPES)
Ejemplo n.º 23
0
def lambda_handler(event, context):
    logger.info(event)
    # logger.info(request)
    return awsgi.response(application, event, context)
Ejemplo n.º 24
0
def lambda_handler(event, context):
    """Main entry point for API gateway."""
    return awsgi.response(app, event, context)
Ejemplo n.º 25
0
def lambda_handler(event, context):
    return awsgi.response(app, event, context)
Ejemplo n.º 26
0
def lambda_handler(event, context):
    return awsgi.response(app,
                          event,
                          context,
                          base64_content_types={"image/png"})
Ejemplo n.º 27
0
def lambda_handler(event, context):
    print("Lambda event", event)
    return awsgi.response(create_app(), event, context)
def handler(event, context):
    lambda_app = create_app(__name__)
    return awsgi.response(lambda_app, event, context)
Ejemplo n.º 29
0
def lambda_handler(event, context):
    # appをAWSGIに渡す
    return awsgi.response(app, event, context)
Ejemplo n.º 30
0
def handle(event, context):
    # Cloudfront isn't configured to pass Host headers, so the provided Host header is the API Gateway hostname
    event['headers']['Host'] = os.environ['SERVER_NAME']
    # Cloudfront drops X-Forwarded-Proto, so the value provided is from API Gateway
    event['headers']['X-Forwarded-Proto'] = 'http'
    return awsgi.response(tiler, event, context)