Question: You are creating a notebook application. Your task is to implement the AWS Lambda function that will perform basic authentication and return the notes of
You are creating a notebook application. Your task is to implement the AWS Lambda function that will perform basic authentication and return the notes of the authenticated user. The notes and authentication data are stored in DynamoDB tables. The lambda function is later exposed through the API Gateway and serves as an HTTP request handler. Runtime for this Lambda handler is Java Notes The DynamoDB table holding notes is named usernotes. Each note has the following attributes: d which is a UUID V; user, which is an owner's email; create date, which is a creation date, stored as a string in ISO format; text, which holds actual note content. Example table rows: Database keys and indexes The table consists of a Partition key user and a Sort key createdate Authentication rn The DynamoDB table holding the authentication data is named tokenemalookup. The table has two fields: token and email. Each authentication token maps to the email of the user owning the given token. The table has a Partition key on the token field. Example table rows: Authentication header Tokens are passed to the lambda through the Authentication HTTP request header. The headers are available in the event. headers object. The Authentication header value takes the Bearer STOKEN format. To query the usernotes table with the user email, you should get it from tokenemailookup ones, reading the token from the HTTP request. Requirements rn Your task is to finish the implementation of the given lambda function. The function should: return the user notes sorted by the create date attribute in descending order return a maximum of notes per query, return an error status if token is invalid or empty Bearer return an error status if the Authentication header is malformed or missing. You can focus on retuming the notes first and sort them later; the operations are scored separately. Technical notes Please note that handleRequest and getAuthenticateduserEmail functions are hooked with a testing framework. Don't change their names and signatures. Of course, you can add new functions. For querying DynamoDB please use specified table objects eg Table table DynamoDBClient client getTabletableName : You can look up their definitions in the official AWS Java DynamoDB SDK documentation.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
