Edit 1: Option 2 below was using a CloudFront function. As an access to DynamoDB is required and cannot be granted to this type of edge function, it has been replaced by a Lambda@Edge. The DynamoDB route has also been added explicitly for both options 1 and 2.
Edit 2: Adding an option 2b that uses an API Gateway as a second origin to the CloudFront distribution. Inspired by this post.
Working on the architecture of my website.
I have a simple index.html
that needs to be served with some CSS styling and Javascript.
Users can also submit an email in a form on that page, they receive a link they need to visit for validation, say /verify-email/{token}.html
. After processing the token on the backend the user is redirected to verified-email/thankyou.html
.
Considering the following three options for the architecture of my website - all on AWS.
Option 1: HTTP API Gateway + Lambda
.html, .css, .js files and images live on both lambdas.
The lambda index
uses a set of these files to render index.html
, the lambda verify-email
uses another set to render verified-email/thankyou.html
(provided the token has been validated with a call to a DynamoDB table).
Option 2a: CloudFront + S3 + Lambda@Edge
.html, .css, and .js all live in the S3 bucket. index.html
and verified-email/thankyou.html
, together with respective .css, .js and images are in that bucket.
The token is processed by the Lambda@Edge function and upon validation redirects to verified-email/thankyou.html
.
Option 2b: CloudFront + S3 + HTTP API + Lambda
Similar to option 2 above.
Questions
Which architecture would you go with for this simple website? What consideration should I keep in mind when choosing an option? (I understand that CloudFront serves content closer to the user, which improves the performance, I am not too bothered on this aspect at that time.)