Reference no: EM133888556
Part 1: Design and implementation of a serverless application using Google Cloud Platform (GCP)
Objective:
Design and implementation of a serverless application using Google Cloud Platform (GCP) that create a basic serverless web application to handles HTTP requests using Google Cloud Functions and stores data in Firestore (a NoSQL database). Hire Online Assignment help service for completing assignment!
Overview of the Application:
The serverless application will have the following functionalities:
An HTTP endpoint using Google Cloud Functions.
Data storage and retrieval using Firestore.
Step 1: Set Up Your Google Cloud Project
Create a Google Cloud Project:
Go to the [Google Cloud Console] and create a new project.
Provide a project name and note down the project ID.
Enable Required APIs:
In the Google Cloud Console, go to `APIs & Services > Library`.
Enable the following APIs:
o Cloud Functions API o
Firestore API
Set Up Billing:
Ensure that billing is enabled for your project (required to use certain GCP services).
Step 2: Install the Google Cloud SDK
Install Google Cloud SDK:
Follow the [installation instructions] for your operating system. (You can skip this part if you already have installed SDK before).
Initialize the SDK:
Run the following command and follow the prompts:
Authenticate and Set Project:
Set your project using:
Step 3: Implement the Cloud Function
Create the Cloud Function Code:
Create a directory for your function:
Create a `main.py` file with the following content:
In this function:
We handle both `POST` and `GET` requests.
For `POST`, the function adds a user's name to Firestore.
For `GET`, the function retrieves and returns the list of users from Firestore.
Create a `requirements.txt` File:
List the required Python packages:
Step 4: Deploy the Cloud Function
Deploy the Function:
Run the following command to deploy your function:
In this command:
`--runtime python310`: Specifies the Python runtime.
`--trigger-http`: Deploys the function as an HTTP endpoint.
`--allow-unauthenticated`: Allows public access to the function (remove this flag if you want restricted access).
Wait for Deployment:
Once deployed, the command line will display a URL for your function, such as:
You can use this URL to make HTTP requests to your serverless application.
Step 5: Test the Serverless Application
Test the GET Request:
You should see a list of users (if any are stored in Firestore).
Test the POST Request:
Use `curl` or a tool like Postman to send a POST request:
This will add a user named "John Doe" to Firestore.
Step 6: View the Data in Firestore
Go to Firestore in Google Cloud Console:
Navigate to `Firestore` in the Google Cloud Console.
You should see a collection named `users` containing the data you added via the POST request.
Step 7: Clean Up Resources
To avoid incurring unnecessary charges, delete the deployed function when you're done:
Conclusion:
This guide demonstrates how to design and implement a serverless application using Google Cloud Functions and Firestore. The application is scalable, easy to deploy, and fully serverless, meaning you don't have to worry about managing infrastructure. This is a basic implementation that you can expand by adding more features, security layers, and integration with other Google Cloud services.
Part 2: Create an AWS Elastic Beanstalk Application Objectives:
In this lab session we are going to create an AWS elastic Beanstalk application.
Overview of the Application:
To run and manage web apps.
Running a web application without having to worry about provisioning the underlying infrastructure layer
Step 1: Create an IAM instance profile for your Amazon EC2 instances
Sign in to the AWS Management Console and open the IAM console at
In the IAM console, in the navigation pane, choose Policies, and then choose Create policy.
On the Specify permissions page, choose JSON.
Remove the example JSON code.
Choose Next.
On the Review and create page, in the Policy name box, type AWS-S3-EC2-Permissions.
(Optional) For Description, type a description for the policy.
Choose Create policy.
In the navigation pane, choose Roles, and then choose Create role.
Under Use case, choose the EC2 use case.
Choose Next.
In the list of policies, select the check box next to the policy you just created (AWS-S3- EC2Permissions). If necessary, use the search box to find the policy.
Choose Next.
On the Name, review, and create page, in Role name, enter a name for the service role (for example, AWS-S3-EC2-Instance-Profile), and then choose Create role. You can also enter a description for this service role in Role description.
Step 2: Set Up Your Elastic Beanstalk Application
Create a Project:
Go to the AWS Management console.
Navigate over Elastic Beanstalk
Select Run and Manage Web Apps
Click Create application
Configure environment:
Select Web server environment.
Application Information:
Provide an application name, which automatically set your Environment Name
Application name and then the environment name are set.
Choose ‘Python' as your Platform.
Keep default settings for the rest.
Click Next
Chose the Service Role:
Select Create and use new service role
Go to EC2 instance profile, and from the drop-down menu, select the IAM Instance Profile you have created in STEP 1
Create Key Pair:
Select the key pair from the drop-down menu.
Click Next
Choose your VPC:
Select your default VPC from the drop-down menu
Go to Instance subnet
Check the Activate option for the Public IP Address
Select a couple of Availability Zones as Instance Subnets
Keep rest of the options as default
Click Next
Configure instance traffic and scaling
Select your Security Group
Choose t2.micro as Instance Type
Keep rest of the parameter as default
Click Next
Configure updates, monitoring, and logging
Choose the System Basic
Uncheck the Activated under the Managed Update
Keep rest of the parameter as default
Click Next
Reviewing Configuration
Review your setting of Elastic Beanstalk application Click Submit
Launching your website
Wait a couple of minutes so that the environment successfully launched
Click the link under Domain to launch your web application.
Connecting to the EC2 Instance
Move on to EC2 instance
Select your instance
Click Connect button on top
Click Connect
You should see the following output, which confirms that your elastic Beanstalk application is running on the EC2 instance: