Serverless helps developers to launch the products faster, paves the way for ideal business implementation and reduces the infrastructure costs at the same time. Basically serverless is cloud computing model which allows the users to write and deploy code without worrying about the backend process. Here the backend process is taken care of by the Cloud provider.
In this cloud computing project, we will try to develop a website by using a serverless architecture. You will use AWS services like AWS DynamoDB, AWS Lambda, AWS API Gateway, AWS S3 and AWS Cloud Front to develop this serverless website.
Skyfi Labs gives you the easiest way to learn and build this project.
Advantages of serverless
Want to develop practical skills on Cloud Computing? Checkout our latest projects and start learning for free
Following are the major applications for serverless: APIs for mobile and web applications, Internet of Things applications, stream and batch processing, cloud automation, etc.
Steps followed:
Start by creating an S3 bucket which holds the front end code for your website. After creating a bucket upload the static site content into the bucket. Refer the following link to learn how to host static website on AWS.
Make the bucket public by clicking on Permissions>Bucket policy and paste the following:
{
“Version”: ”2020-4-14”,
“Statement”:{
{
“Effect”: “Allow”,
“Principal”: “*”,
“Action”: “s3:GetObject”,
“Resource”: “arm:aws:s3:::[your_bucket_name]/*”
}
}
}
Don’t forget to change the bucket name in the code. Click Save.
Now click properties and select the card “Static website hosting” and check “Use this bucket to host a website” input the index.html then click save.
You can check your static website by clicking on the endpoint link. Set up an instance of the Amazon Cognito, which enables us to register and login securely.
Now go to Amazon cognito and click manage user pools. Click create a user pool and give a name and click on Review defaults. Here you can review the defaults and click create. Note down the pool ID and endpoint. Create an app client and save the client ID for future use. Using the client ID you can get benefitted from various Cognito APIs like login and register.
Head on to DynamoDB and create a table. Give a table and choose a primary key as per your wish. In the Items tab, you can create and modify the tables. Now we have a database.
Now we need to create a role to access the database to read and write using Identity and Access Management
Go to IAM and create a role then click on Lambda then next. In the filter policies tab type lambda and select “AWSLambdaBasicExecutionRole” Click next and provide a name and click create role.
Now attach a policy to our database by clicking on add inline policy. Under visual editor tab choose the service as DynamoDB. For actions select all DynamicsDB actions.
Click Resources and select specific option and select Add ARN under table. Now paste the ARN number of your database and click add. Click Review policy and give a name to your policy and click create. Once the role is created we are ready to create the lambda function.
For that go to AWS lambda click create function. Select “Author from scratch” and choose the Runtime as Node.js and the role.
Now you can see, it has access to the Amazon CloudWatch Logs and Amazon DynamoDB database.
Now create an API Gateway for each function. API Gateway which connects all the services together. Give a name to the API and choose the endpoint as edge optimized and click on create API.
Goto actions and create a method and select lambda, click save.
Now your API gateway is ready to deploy. The serverless web app functionality is now complete now you have a static website sitting in S3 storage with all the images, CSS, and HTML files then the user pool Amazon Cognito to manage login register and authentication followed by the newly created database which is manipulated by various lambda functions.
Skyfi Labs helps students learn practical skills by building real-world projects.
You can enrol with friends and receive kits at your doorstep
You can learn from experts, build working projects, showcase skills to the world and grab the best jobs.
Get started today!
Join 250,000+ students from 36+ countries & develop practical skills by building projects
Get kits shipped in 24 hours. Build using online tutorials.
Stay up-to-date and build projects on latest technologies