Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except ScopeMissing as error:
error_description = "Permission denied"
logging.warning(
logging_message.format(status_code=403, message=error_description)
)
error_tuple = (error_description, 403)
except Exception as error:
if error_handler:
error_handler(error, method_name)
else:
raise
body, status_code = error_tuple
return Response(body, status_code).to_json(
application_load_balancer=application_load_balancer
)
def inner_lambda_handler(event, context=None):
# check if running as "aws lambda proxy"
if (
not isinstance(event, dict)
or not all(key in event for key in __required_keys)
or not any(key in event for key in __either_keys)
):
message = "Bad request, maybe not using Lambda Proxy?"
logging.error(message)
return Response(message, 500).to_json(
application_load_balancer=application_load_balancer
)
# Save context within event for easy access
event["context"] = context
# for application load balancers, no api definition is used hence no resource is set so just use path
if "resource" not in event:
resource = event["path"]
else:
resource = event["resource"]
# Fill placeholders in resource path
if "pathParameters" in event:
resource = check_update_and_fill_resource_placeholders(
resource, event["pathParameters"]
)