0% found this document useful (0 votes)
54 views86 pages

CC Practical New

Uploaded by

21amtics440
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views86 pages

CC Practical New

Uploaded by

21amtics440
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

202103103510299

Practical 1

Aim: Create an Amazon Kinesis Stream.


Overview: In this practical, we are going to use AWS lambda for deploying a
simple function.

Step-1: Login to AWS account.


Step-2: Search for Lambda Function.

Cloud Infrastructure and Resource Management


202103103510299

Step-3: Click on create option.

Step-4: Select author from scratch.


Step-5: Give name to function.
Step-6: Select Python as runtime.
Step-7: Architecture can be x86_64 or arm [ARM is cheaper].

Cloud Infrastructure and Resource Management


202103103510299

Step-8: Create a new role with basic lambda permission.

Step-9: Enable function URL.

Cloud Infrastructure and Resource Management


202103103510299

Step-10: Invocation mode buffered.


Step-11: Click on Create.

Step-12: It will create a blank lambda function and also give a url using which lambda function
can be invoked.

Cloud Infrastructure and Resource Management


202103103510299

Step-13: In the code part you can write code in python as runtime is python.
Step-14: Event will contain all user specified events which are passed while invoking lambda
function.
Step-15: In python it will follow flask framework format to execute code.
Step-16: Code will return status code and response body.
Step-17: Click on deploy and it will publish the lambda function.
Step-18: You can click on the function URL to execute the function.

Cloud Infrastructure and Resource Management


202103103510299

Step-19: Modify code and add an event inside the body to see all received events.

Cloud Infrastructure and Resource Management


202103103510299

Step-20: Now modify code to print greetings to users so that you can get
‘queryStringparameters’ from events and then get required parameters.
Step-21: Use(“hello {} {}”.format(first_name,last_name) to print hello `first_name` and
`last_name`).
Step-22: Code
Import json
Def lambda_handler(event, context):
first_name=event[‘queryStringParameters’][‘first_name’
]
last_name=event[‘queryStringParameters’][‘last_name’]
Return {
‘statusCode’: 200,
‘body’: json.dumps(“hello {} {}” .format(first_name,last_name))
}

Cloud Infrastructure and Resource Management


202103103510299

Step-23: Delete Lambda Function.

Cloud Infrastructure and Resource Management


202103103510299

Cloud Infrastructure and Resource Management


202103103510299

Practical 2

Aim: Building a web application. Students can build a simple web application
using Platform as a Service (PaaS) provider and deploy it to the cloud.

Overview: In this practical, we are going to deploy a website on using beanstalk in


AWS

Step-1: Search for IAM.

Cloud Infrastructure and Resource Management


202103103510299

Step-2: Click on create role.


Step-3: Select aws service in trusted entity & usecase as EC2.

Step-4: Click next to add permission. From that select following permission:
● AWSElasticBeanstalkWebTier
● AWSElasticBeanstalkWorkerTier
● AWSElasticBeanstalkMulticontainerDocker

Cloud Infrastructure and Resource Management


202103103510299

Step-5: Click on next and give EBS-role.

Step-6: Once a role is created go to elastic beanstalk.

Step-7: Create Application.


Step-8: Select webserver.
Step-9: Give application name.

Cloud Infrastructure and Resource Management


202103103510299

Step-10: Keep an auto generated application environment.

Step-11: Select managed platform.


Step-12: Select platform as PHP.

Cloud Infrastructure and Resource Management


202103103510299

Step-13: Keep version and platform version default.

Step-14: In application code select upload code.


Step-15: Give a version label like s1.
Step-16: Select Local File.
Step-17: Upload Zip File.

Cloud Infrastructure and Resource Management


202103103510299

Step-18: In present single instance free tier.


Step-19: Select use an existing service role.
Step-20: Select EC2 pair if you have or just keep blank.
Step-21: EC2 instance profile select EBS-role which we have created earlier.
Step-22: Click on skip to review

Cloud Infrastructure and Resource Management


202103103510299

Step-23: Click to create.


Step-24: Once it is submitted it will give a success message (it will take some time).

Step-25: Open provider url and your application will be available.

Cloud Infrastructure and Resource Management


202103103510299

Step-26: Go to the application version and delete the version.

Cloud Infrastructure and Resource Management


202103103510299

Step-27: Terminate application environment.

Cloud Infrastructure and Resource Management


202103103510299

Step-28: Delete Application.

Cloud Infrastructure and Resource Management


202103103510299

PRACTICAL-3

(A): Deploying a static website in Amazon S3.

Overview: AnyCompany Ice Cream would like you to create a static website
which displays their ice cream flavors. We will configure and use S3 bucket to
deploy our static website.

Step-1: Login to AWS Builder Lab & Download the Zip file.

Step-2: Stare the Lab & Search for S3.

Cloud Infrastructure and Resource Management


202103103510299

Step-3: There are already two buckets are available click on Second Lab Stack Bucket

Step-4: Click on upload.


Step-5: Add Files & the Folder.

Cloud Infrastructure and Resource Management


202103103510299

Step-6: Click on Upload.

Step-7: Uploaded Succeeded.

Cloud Infrastructure and Resource Management


202103103510299

Step-8: Go to Static website hosting and Click on the URL.

Cloud Infrastructure and Resource Management


202103103510299

Cloud Infrastructure and Resource Management


202103103510299

(B) : Verify the dynamic on Amazon EC.

OverView: In this task, verify if the new dynamic website is working and that data
about the inventory for available ice cream Flavors is returned from the database.

Step-1: Search for EC2.

Step-2: Select the Ice Cream Instance.

Cloud Infrastructure and Resource Management


202103103510299

Step-3: Copy the Public IPv4 Address & paste on the browser.

Cloud Infrastructure and Resource Management


202103103510299

(C) : Update dynamic website to a server-less solution using DynamoDB for


the MySQL database.

Overview: In this task, we will create a new ice cream flavor in the Products
table using the Amazon DynamoDB console.

Step-1: Search for DynamoDB.

Step-2: Already one table is available & click on the produce table.

Cloud Infrastructure and Resource Management


202103103510299

Step-3: Go to Explore table items.

Step-4: Click on Create item.

Cloud Infrastructure and Resource Management


202103103510299

Step-5: Give the id partition key value 1.

Step-6: Add new attributes & values then click on create items.

Cloud Infrastructure and Resource Management


202103103510299

Step-7: The Item has been saved successfully.

Step-8: Go to EC2 & check the instance and connect.

Cloud Infrastructure and Resource Management


202103103510299

Step-9: Click to connect.

Step-10: It will launch the EC2 Terminal.

Cloud Infrastructure and Resource Management


202103103510299

Step-11: Write the command /var/www/html/migrate-database.sh

Step-12: Open the EC IPv4 URL.

Cloud Infrastructure and Resource Management


202103103510299

Practical-4

(A) : Create an Amazon Kinesis Stream

Overview: In this practical, we will learn about how we can create a data stream
using Amazon Kinesis

Step-1: Search for Kinesis Stream.

Cloud Infrastructure and Resource Management


202103103510299

Step-2: Select Kinesis Data Streams & Click to create data stream.

Step-3: Give name to data stream.


Step-4: Select Provisioned Capacity mode & Click on Create data Stream.

Cloud Infrastructure and Resource Management


202103103510299

Step-5: Lab-Stream successfully created.

Cloud Infrastructure and Resource Management


202103103510299

(B) : Create a Lambda Function using Amazon Lambda.

Overview: In this task, you will define an AWS Lambda function that will be
triggered by data coming into the stream.
Step-1: Search for Lambda.

Cloud Infrastructure and Resource Management


202103103510299

Step-2: Click on Create a Function.

Step-3: Click on Use a blueprint.


Step-4: Give Blueprint name (Process records sent to a kinesis stream python3.8).
Step-5: Give Function name (ProcessKinesisRecords).
Step-6: Select Use an existing role.
Step-7: Existing role(lambda_basic_execution).

Cloud Infrastructure and Resource Management


202103103510299

Step-8: Write Lambda function code.

Cloud Infrastructure and Resource Management


202103103510299

Step-9: In the Kinesis trigger section Select Kinesis Stream (Which We have created earlier) &
Create Function.

Cloud Infrastructure and Resource Management


202103103510299

Step-10: Lambda Function has been Successfully Created.

Cloud Infrastructure and Resource Management


202103103510299

(C) : Test your Lambda Function.


Overview: In this task, you will simulate data coming from a stream to trigger
your Lambda Function.

Step-1: Select create new event.


Step-2: Give Event name to stream.
Step-3: Write the event JSON file.

Cloud Infrastructure and Resource Management


202103103510299

Step-4: Click on Save in Text event.

Cloud Infrastructure and Resource Management


202103103510299

Step-5: Click on Test in Test event.

Step-6: Click on Moniter.

Cloud Infrastructure and Resource Management


202103103510299

(D) : Create Tables in DynamoDB.

Overview: In this task, you will create a DynamoDB table that contains scores for
online games.

Step-1: Search for DynamoDB.

Step-2: Click on Create Table.

Cloud Infrastructure and Resource Management


202103103510299

Step-3: Give table name GameScoreRecords & Partition key RecordID(Number).

Step-4: Create Table.

Cloud Infrastructure and Resource Management


202103103510299

Step-5: Create another table name GameScoreByUser & five Partition Key Username(String).

Cloud Infrastructure and Resource Management


202103103510299

Step-6: Create Table.

Step-7: Table created Successfully.

Cloud Infrastructure and Resource Management


202103103510299

Step-8: Select GameScoreRecords.

Step-9: Go to Exports and streams & turn on the DynamoDB Stream.

Cloud Infrastructure and Resource Management


202103103510299

Step-10: Select New image and Turn on Stream.

Step-11: Successfully turn on streaming to the DynamoDB stream.

Cloud Infrastructure and Resource Management


202103103510299

Cloud Infrastructure and Resource Management


202103103510299

(E) : Create a Lambda Function that will be triggered by updates to the


DynamoDB.

Overview: In this task, you will create a Lambda function that will be triggered by
updates to your DynamoDb table.

Step-1: Search for Lambda.

Cloud Infrastructure and Resource Management


202103103510299

Step-2: Create a new Function.

Step-3: Select Author from scratch.


Step-4: Give Function name to AggregateScoreByUser.
Step-5: Select Runtime Node.js 16x.
Step-6: Select Architecture x86_64.

Cloud Infrastructure and Resource Management


202103103510299
Step-7: Select Use an existing role.
Step-8: Select existing role(lambda_basic_execution_dynamodb) & Create Function.

Step-9: Successfully Created.

Cloud Infrastructure and Resource Management


202103103510299

Step-10: In the code part change the index.js code & deploy.

Cloud Infrastructure and Resource Management


202103103510299

Step-11: Click on Add trigger.

Step-12: Select DynamoDB.


Step-13: In the DynamoDb table select GameScoreRecords.
Step-14: Add.

Cloud Infrastructure and Resource Management


202103103510299

Cloud Infrastructure and Resource Management


202103103510299

Step-15: Test the Function.

Step-16: Change the JSON code.

Cloud Infrastructure and Resource Management


202103103510299

Step-17: Save the Function.

Step-18: Test the Function

Cloud Infrastructure and Resource Management


202103103510299

Step-19: Search DynamoDB.

Cloud Infrastructure and Resource Management


202103103510299

Step-20: Already we have created two tables: select GameScoreRecords and Click on Explore
Items.

Step-21: Click on Create Item.

Cloud Infrastructure and Resource Management


202103103510299

Step-22: Give RecordID(Partition Key) Value 1.

Step-23: Add new Attribute Username(string) and Score(Number) with values.


Step-24: Click on Game Item.

Cloud Infrastructure and Resource Management


202103103510299

Step-25: Item has been saved successfully.

Step-26: Click on GameScoreByUser.

Cloud Infrastructure and Resource Management


202103103510299

Practical 5

(A) : Create and run a blank app in AWS Cloud9.

Overview: In this task, you will use CRA to generate the React development
environment for your EC2 Vendor app. You will also start a local debugging
session to preview your running app.

Step-1: Search for Cloud9.

Cloud Infrastructure and Resource Management


202103103510299

Step-2: Click on open(Cloud-IDE).

Cloud Infrastructure and Resource Management


202103103510299

Step-3: Run the following commands:


cd ~/environment
npx create-react-app ec2-vendor

Cloud Infrastructure and Resource Management


202103103510299

Step-4: Add Dependencies

Cloud Infrastructure and Resource Management


202103103510299

Step-5: Click on Preview -> Preview Running Application

Cloud Infrastructure and Resource Management


202103103510299

(B) : Update the React app to use traditional HTML elements for the EC2
Vendor app.

Overview: In this task, you will remove the CRA-created content and use standard
HTML elements to build an outline of your app.

Step-1: Write command in terminal:


cp~/environment/lab-resources/frontend/example1/*~/environment/ec2-vendor/src

Cloud Infrastructure and Resource Management


202103103510299

(C) : Update the app to use Amplify UI components.


Overview: In this task, you will use Amplify UI, a component library, instead of
HTML elements to build your app. A component library is a repository of
customizable and reusable components that allow developers and designers to
work consistently and save time.
Step-1: cd ~/environment/ec2-vendor
Step-2: npm install @aws-amplify/ui-react

Cloud Infrastructure and Resource Management


202103103510299

Step-3: cp ~/environment/lab-resources/frontend/example2/* ~/environment/ec2-vendor/src

Cloud Infrastructure and Resource Management


202103103510299

(D) : Update the react app and add states.


Overview: In this task, you will update your app to support a dark or light theme,
allow loading states in the buttons, and implement conditional rendering.

Step-1: cp ~/environment/lab-resources/frontend/example3/* ~/environment/ec2-vendor/src

Cloud Infrastructure and Resource Management


202103103510299

(E) : Update the app to include effects, props and a reusable component.
Overview: In this task, you will update your app with the ability to dynamically
add and remove instances.

Step-1: cp ~/environment/lab-resources/frontend/example4/* ~/environment/ec2-vendor/src

Cloud Infrastructure and Resource Management


202103103510299

(F) : Create an Amplify app using the CLI and add authentication services.
Overview: In this task, you will install the Amplify CLI, create an Amplify app
with an AWS Identity and Access Management (IAM) permissions boundary,
and add authentication services based on Amazon Cognito.
Step-1: npm install -g @aws-amplify/cli

Step-2: Add Policy


Step-3: cd ~/environment/ec2-vendor
Step-4: amplify init –permission-boundary $policy_arn
Step-5: Enter a name for the project ec2vendor.

Cloud Infrastructure and Resource Management


202103103510299

Step-6: Press Y in configuration.

Step-7: Authentication method: AWS profile.


Step-8: Choose Profile: default.

Cloud Infrastructure and Resource Management


202103103510299

Step-9: amplify add auth.


Step-10: authentication configuration & Security configuration : Default configuration
Step-11: Sign In: Username
Step-12: Advanced settings: No, I am done.

Step-13: Amplify push –yes.

Cloud Infrastructure and Resource Management


202103103510299

(G) : Update the app to use authentication.


Overview: In this task, you will update your app with the authentication
capabilities.
Step-1: cd ~/environment/ec2-vendor.
Step-2: npm install aws-amplify.

Step-3: cp ~/environment/lab-resource/frontend/example5/* ~/environment/ec2-vendor/src

Cloud Infrastructure and Resource Management


202103103510299

(H) : Create an AWS Lambda function which takes input from an API and
interacts with the EC2 service using the AWS SDK .
Overview: In this task, you use Amplify to create a Node.js Lambda function
that takes input from an API and interacts with the EC2 service using the AWS
SDK. This includes getting Amazon Machine Image (AMI) data, querying,
starting and terminating EC2 instances.

Step-1: cd ~/environment/ec2-vendor
Step-2: amplify add function.
Step-3: capability you want to add: Lambda function (serverless function).
Step-4: lambda function name: ec2VendorApi.
Step-5: runtime NodeJS.
Step-6: function template: Hello World. Step-7: Configure Advanced Setting: No. Step-8: Edit
the local Lambda function:

Step-9: cp -rp ~/environment/lab-resources/backend/ec2VendorApi/* ~/environment/ec2-


vendor/amplify/backend/function/ec2VendorApi
Step-10: cd ~/environment/ec2-vendor/amplify/backend/function/ec2VendorApi/src/

Cloud Infrastructure and Resource Management


202103103510299

Step-11: npm install aws-sdk

Step-12: amplify mock function ec2VendorApi --event “src/event.json”

Cloud Infrastructure and Resource Management


202103103510299

Cloud Infrastructure and Resource Management


202103103510299

(I) : Create a secure REST API backed by an AWS Lambda function.


Overview: In this task, you will use Amplify to create a secure REST API
powered by Amazon API Gateway. This is backed by the Lambda function which
you created in the previous task.

Step-1: cd ~/environment/ec2-vendor.
Step-2: amplify add api.
Step-3: Select REST service.
Step-4: Give label name vendorApi for project.
Step-5: Provide Path : /vendor.
Step-6: Lambda source: Use a Lambda function already added in the current Amplify project.
Step-7: Restrict API access? YES.
Step-8: Who should have access? Authenticated user only.
Step-9: What Permission do you want to grant to Authenticated users? Create, Read,
Update,Delete.
Step-10: Do you want to add another path? NO.

Cloud Infrastructure and Resource Management


202103103510299

Step-11: amplify push --yes.

Cloud Infrastructure and Resource Management


202103103510299

(J) : Update the app to use the API to query Amazon Linux 2 AMI data.
Overview: In this task, you will update your app to interact with the secure
REST API and query for Amazon Linux 2 AMI data based on x86_64 or arm64
architecture.

Step-1: Click on Create Account & Fill the form.


Step-2: A verification code will be sent to your email.
Step-3:cp~/environment/lab-resource/frontend/example6/*~/environment/ec2-vendor/src

Step-4: A Welcome page will be appear.

Cloud Infrastructure and Resource Management


202103103510299

Step-5: cp ~/environment/lab-resource/frontend/example7/* ~/environment/ec2-vendor/src

Cloud Infrastructure and Resource Management


202103103510299

(K) : Host the app on Amazon CloudFront.


Overview: In this task, you will use Amplify to add hosting and deploy your app to
Amazon CloudFront.

Step-1: cd ~/environment/ec2-vendor.
Step-2: amplify add hosting.

Cloud Infrastructure and Resource Management


202103103510299

Step-3: amplify publish –yes.

Step-4: Click on Launch.

Cloud Infrastructure and Resource Management


202103103510299

(L) : Cleanup the Web application.


Overview: In this task, you will use the AWS Amplify CLI to remove all resources
you built during the lab: Cognito user and identity pools, API Gateway REST API,
Lambda function and CloudFront hosting.

Step-1: cd ~/environment/ec2-vendor.
Step-2: amplify delete.

Cloud Infrastructure and Resource Management

You might also like