My current situation: I have an AWS API Gateway with a resource /login. When there is a GET request on this resource, an AWS Lambda function is called which returns an HTML login form. The HTML for the login form is written inside a JavaScript string in the Lambda function (I'm using Node JS inside my Lambda functions). When the form is submitted, the same resource - /login with POST method calls another Lambda function which validates the login. If the login fails, it returns an HTML form with validation error messages, but again, the HTML code is written inside a JavaScript string.
My question:
Is it possible to store an HTML file in an AWS S3 bucket, so when I hit /login the API Gateway calls the Lambda function, which then gets the HTML page from S3 bucket and returns it to the user?
And when the form validation fails, then I'd like to return the same HTML from S3 bucket with added error messages.
Is it possible to interconnect these components in this way? The part I'm struggling with is storing HTML on S3 and accessing it from Lambda.