I want visitors of my website to be able to provide their email address in a form to get future company updates. Once they submit the form an email would be sent to their address with a link to click on, say www.mywebsite.com/<token>
. Upon visiting that link their email would be validated and become part of the database I would use to send updates.
I have in mind deploying my website using AWS S3 together with AWS CloudFront and AWS Certificate Manager. For the implementation of the email verification process: a Lambda function would be triggered through API Gateway when a user submits the form, the token would be generated in that function, and an email would be sent to the visitor with a call to AWS SES.
I'm having issue understanding within that framework how I can create dynamically and serve URLs of the form www.mywebsite.com/<token>
. I can see that with a server up and running in the backend, this could be achieved with something along the lines of
const express = require('express')
const app = express()
app.get('/verify-email/:token', async (req, res) => {
const token = req.params.token;
// check token
// if match, validate email, add to database, and render page
// if no match, redirect
});
How can I create and serve these URLs within the S3 framework I detailed above?
Do I need otherwise to change the implementation and run instead an EC2 server or use another AWS service?