DEV Community

Discussion on: How to Build a Serverless Web Application

Collapse
 
ben10 profile image
Ben Honda

Good read. One question I have - what kind of URL is outputted when we deploy the S3 bucket? Is it a “s3.website”-type url, or a special serverless url? The reason I ask is I’m confused how we are able to submit the form to ‘/submit-contact’ and don’t have to use a fully qualified domain or lambda function URL. Thanks for the article

Collapse
 
ritikbanger profile image
Ritik Banger

When you deploy the S3 bucket for your serverless web application, the URL typically takes the form of "bucket-name.s3-website-region.amazonaws.com." This is known as a "static website hosting" URL, specific to S3 hosting.

Regarding submitting the form to '/submit-contact' without using a fully qualified domain or Lambda function URL, in a typical serverless setup with AWS, you would likely employ API Gateway to create a custom RESTful API endpoint like '/submit-contact'. This API Gateway endpoint would be configured to trigger your Lambda function directly. So, although the endpoint appears to be relative, behind the scenes, API Gateway is handling the routing to the appropriate Lambda function.

In the current scenerio, you can see that we have created this endpoint.

functions:
  app:
    handler: handler.handler
    events:
      - http:
          path: submit-contact
          method: post
          cors: true
    environment:
      CONTACTS_TABLE: ${self:service}-contacts-${opt:stage, self:provider.stage}
Enter fullscreen mode Exit fullscreen mode

Some comments have been hidden by the post's author - find out more