Package: aws-lambda-mess
OverviewThis is an extremely simple framework to facilitate developing rest services running as lambda services in aws.FeaturesVERY simpleOne lambda function required to host a whole rest serviceAllows for local developmentShortcomingsOnly supports PythonDoes not support non json responsesQuery variables not supported yetHeaders not exposed in route handlersMany othersPlease raise issues for any enhancements or bugs.TheFAQ, always theFAQ.IndexWorkflow in a nutshellInstallingCreate and run a new projectBuild the aws lambda zipInstall the zip as a lambdaConfigure the api gatewayDeveloper sectionWorkflow in a nutshellInstallCreate projectDevelop and test locallyBuild zip file for aws lambdaUpload to awsIf not done goto 3InstallingInstall the package using pip:pipinstallaws_lambda_messAfter a successful installation check that the cli works:alm--helpCreate and run a new projectCreate a new project using the cli:almnewdemoThis will:create a new directory with the name you specifiedpopulate the directory with some standard boilerplateA sample app has been created for you insrc\app.pyfromaws_lambda_mess.framework.RouteimportRoutefromaws_lambda_mess.framework.successimportsuccessfromaws_lambda_mess.framework.failuresimportbad_requestfromaws_lambda_mess.framework.serverimportrundefindex(params,body):returnsuccess({"Hallo":"Index"})defgreet(params,body):returnsuccess({"Hallo":params["name"]})defdefault(params,body):returnbad_request()routes=[Route(method_pattern="GET",path_pattern="/greet/<name>",handler=greet),Route(method_pattern=".*",path_pattern=".*",handler=default)Route(method_pattern="GET",path_pattern="/",handler=index),]fromaws_lambda_mess.framework.lambda_dispatcherimportget_handlerlambda_handler=get_handler(routes)if__name__=="__main__":run(9000,routes)To run the app locally simply run:pythonapp.pyA webserver serving the above routes  will spin up on port 9000$curl-XGETlocalhost:9000/{"Hallo":"Index"}$curl-XGETlocalhost:9000/greet/somebody{"Hallo":"somebody"}$curl-XGETlocalhost:9000/whatwhere-v
Note:Unnecessaryuseof-Xor--request,GETisalreadyinferred.
*Trying127.0.0.1:9000...
*Connectedtolocalhost(127.0.0.1)port9000(#0)>GET/whatwhereHTTP/1.1
>Host:localhost:9000
>User-Agent:curl/7.88.1
>Accept:*/*
>
*HTTP1.0,assumecloseafterbody
<HTTP/1.0400BadRequest
<Server:BaseHTTP/0.6Python/3.9.13
<Date:Sun,30Apr202306:38:25GMT
<
*Closingconnection0Build the aws lambda zipTo build the package to be uploaded to aws simply run:almbuildThis will create a zip file in thedistdirectory calledpackage.zipUpload this package to aws lambda either in the lambda console or via s3.Install the zip as a lambdaOnce the package has been uploaded change thehandlersetting under runtime settings toapp.lambda_handlerNow test the package with some of these json test cases:Test /{"body":"{}","resource":"/{proxy+}","path":"/","httpMethod":"GET","isBase64Encoded":true}Returns{"isBase64Encoded":false,"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{\"Hallo\": \"Index\"}"}Test /greet/somebody{"body":"{}","resource":"/{proxy+}","path":"/greet/somebody","httpMethod":"GET","isBase64Encoded":true}Returns{"isBase64Encoded":false,"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{\"Hallo\": \"somebody\"}"}Test invalid route or method{"body":"{}","resource":"/{proxy+}","path":"/greet/somebody","httpMethod":"POST","isBase64Encoded":true}{"isBase64Encoded":false,"statusCode":400}This json gets converted to a proper http response by the proxy.Configure the api gatewayThe API gateway you attach to the lambda needs to look like thisand the methods needs to be defined to look like this:Developer sectionRun tests???Build aws_lambda_messhatchbuildUpload to pippy-mtwineuploaddist/*--userjohanjordaan