3

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

enter image description here

.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

enter image description here

.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

enter image description here

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.)

  • 1
    S3 might be a little cheaper since you aren't paying to spin up containers just for the index.html page. It might also be easier to update, though you need to remember to invalidate the files with Cloudfront once you update them. – Dave S Aug 16 '23 at 19:33
  • Thanks @DaveS! Re cost, this was my initial feeling too; the argument on the ease of udpate is a good one to have in mind, thanks. – KeyboardOnFire Aug 16 '23 at 20:07

0 Answers0