You are on page 1of 21

Architecting a website using the Serverless Technology.

Description:
In the ‘serverless’ way of doing things, we don’t need to think about servers. Because, the capacity planning, scaling,
high availability, and fault tolerance — typically expected of a server — are automatically managed by Cloud
provider. In this case, we will consider AWS (cloud provider). AWS offers a plethora of services that follow the
serverless model, including but not limited to SNS, SQS, Lambda, and SES. One can use these services just by
subscribing to them and without actually contacting the server. This eliminates the need to split your attention to
ensure all systems are updated and maintained, allowing you to spend more time on the core operations of your
business.
Often, companies take feedback from their customers. A book publishing company, for instance, takes the feedback
on the newly published book. A cosmetic company takes feedback, on the newly launched cosmetic product. So,
after collecting the customer feedback, companies tend to aggregate them all to comprehend the most common
issues with the product, and accordingly tweak the product and the marketing strategy designed for the product.
Until now, taking the feedback required creating an EC2 instance, RDS Database, etc. But, in this use case, we will
use the `serverless` technologies to build up a feedback website.

Steps to be perfomed:
 S3 – For storing the web pages
 DynamoDB – For storing the feedback results
 Cognito – To provide the website access to the backend database
 IAM – To specify what permissions to be given

1. For storing the web pages


 Open aws console and search and open s3 service.
 Click on create bucket. Name the bucket as ‘registration form’.

 Uncheck ‘block public access settings’


 Check the acknowledgesetting and click on create.

 After creating the bucket, click on upload file.


 Upload register form ,which having sign in and sign up form.
 After uploading the file. Go to properties tab, and enable static web hosting.
 And specify the index document which we upload in the bucket.

 And go to permissions tab, and select bucket policy,


● To give public read access for the static website, enter the following code in the Bucket
policy editor, and then click on the Save button

"Version": "2012-10-17",

"Statement": [

"Sid": "PublicReadGetObject",

"Effect": "Allow",

"Principal": "*",

"Action": [

"s3:GetObject"

],

"Resource": [

"arn:aws:s3:::Registration-form/*"

}
 Now create a another bucket naming feedback form ,same as previous bucket.

 Also block public access setting and upload feedback.htmlfile in the bucket.
 Go to properties tab and enable static web hosting as previous step and specify the index
document.
 And set permissions, to give public read access.

2. For storing the feedback results


 Search and open dynamodb

 Click on create table, and name the table.


 Give a name to partition table, which is primary key.

 Click on create.
3. To specify what permissions to be given
 Open IAM service in aws console.
 Click on roles under access management and click on create roles.

 Select aws service as a trusted entity type, and lambda as a use case.

 Click on next
 In add permissions step, search for amazon apigateway administrator, and amazon
dynamodb fullaccess.

 Click on create role.

4. To provide the website access to the backend database


 In aws console, search and open cognito services.

 Select configure user pool , And click next.


 Give a user pool name.

 Copy the url feedback.html from the feedback bucket and paste it in the callback URL.
 Check availability and give amazon coginto domain. And click save button.

 Copy the userpool id and app client id.


 Create a java script file which is used to invoke aws cognito, paste the
userpoolId,region,clientid.

 Save this file in the register bucket.

5.lambda function
 Search and open lambda
 Click on create function

 Chose author from scratch, and name the function.


 And runtime as python
 In permissions choose the created IAM policy
 Click on create function.

6.API gateway
 Open aws console and search for api gateway.

 Chose rest api and new api.


 Name the api

 Click on create.
 Under the api tab on resources,click actions tab and click on create resource and name
the resource and click create.

 Enable CORS and replace existing CORS headers.


 Select post setup and choose lambda function as integration type, and below select the
lambda function we created in previous step. Click on save.

 Now deploy the api give a stage name and click on deploy.
 Now the inoke url has been created, copy the url.

 Paste it in the java script function in feedback.html file save and upload the updated file
in the same feedback bucket.

 In the lambda envinronment type the below code , to save the results in the dynamodb.
 Click on deploy and save.

 Now open the registration URL form,


 Enter your Name, email address, password and confirm the password.
 Click on register.
 Check your email for verification link and click verify.

 Now in the sign in page , enter your credentials we created before.


 You’ll redirected to feedback webpage.
 Fill the name , email id and overall experience. And click on submit button.

 Now open the dynamodb and check for the results.

 Thus Architecturing a website using serverless technology and has been


completed and document has been provided.

You might also like