This is a serverless web application hosted on AWS using the following services:
- Amazon S3
- Amazon CloudFront
- AWS Route 53
- AWS Lambda
- Amazon API Gateway
- Amazon DynamoDB
- Amazon SNS
The architecture of this serverless web application is as follows:
-
Route 53:
- Domain Management: AWS Route 53 is used to manage your domain names and DNS settings, ensuring that your web application can be accessed via a user-friendly URL.
-
CloudFront:
- Content Delivery Network (CDN): Amazon CloudFront is used to distribute your web content globally with low latency and high transfer speeds. It caches the content stored in S3 and serves it to users.
-
S3 (Simple Storage Service):
- Static Content Hosting: Amazon S3 is used to host your static web content (HTML, CSS, JavaScript, images, etc.). CloudFront fetches this content from S3 to deliver it to users.
-
API Gateway:
- API Endpoint Management: Amazon API Gateway acts as the entry point for your application's backend. It handles all the API calls from the client, invoking Lambda functions to process these requests.
-
Lambda:
- Serverless Compute: AWS Lambda is used to run your backend code without provisioning or managing servers. When a user submits the form, API Gateway triggers a Lambda function to process the form data.
-
DynamoDB:
- Database: Amazon DynamoDB is used to store the form data. The Lambda function inserts the user-submitted data into a DynamoDB table for persistent storage.
-
SNS (Simple Notification Service):
- Notifications: Amazon SNS is used to send email notifications. The Lambda function publishes a message to an SNS topic when a user submits the form, triggering an email notification to the admin.
-
User Request:
- The user accesses the web application via a custom domain managed by Route 53.
-
Content Delivery:
- The user's request is routed through CloudFront, which serves static content from S3.
-
Form Submission:
- When the user submits a form, the browser sends a request to API Gateway.
-
API Gateway:
- API Gateway receives the form submission and invokes a Lambda function.
-
Lambda Function:
- The Lambda function processes the form data. It saves the data to DynamoDB.
- The Lambda function also publishes a message to an SNS topic.
-
SNS Notification:
- SNS sends an email notification to the admin based on the message published by the Lambda function.
Here’s a visual representation of this architecture:
User
⬇
Route 53 (Custom Domain)
⬇
CloudFront (CDN)
⬇
S3 (Static Web Content)
⬇
API Gateway (API Management)
⬇
Lambda (Backend Logic)
⬇ ⬇
DynamoDB (Data Storage) SNS (Notifications)
⬇
Admin Email Notification
- AWS Management Console access
- Serverless Framework
- Open the AWS Management Console.
- Navigate to S3.
- Create a new bucket (e.g., your-website-bucket).
- Enable static website hosting in the properties of the bucket.
- Upload index.html and form.html to the bucket.
- Navigate to CloudFront in the AWS Management Console.
- Create a new distribution.
- Set the origin domain to your S3 bucket.
- Configure the distribution settings as needed.
- Use AWS Certificate Manager (ACM) to create a certificate for your domain and attach it to the CloudFront distribution.
- Navigate to Route 53 in the AWS Management Console.
- Create a hosted zone for your domain.
- Add a record set to point to the CloudFront distribution.
- Navigate to API Gateway in the AWS Management Console.
- Create a new REST API.
- Create a new resource and method (e.g., POST /submit).
- Integrate the method with a Lambda function.
- Navigate to Lambda in the AWS Management Console.
- Create a new function with Python 3.9 runtime.
- Copy and paste the content from lambda\handler.py into the function editor.
- Set up the necessary IAM roles and permissions for the Lambda function to access DynamoDB and SNS.
- Navigate to DynamoDB in the AWS Management Console.
- Create a new table (e.g., UserSubmissions) with id as the primary key.
-
Navigate to SNS in the AWS Management Console.
-
Create a new topic (e.g., FormSubmissionTopic).
-
Subscribe your email to the topic.
sh npm install
By following this order and structure, you can create a scalable and efficient serverless web application using AWS services.
