Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Class notes Internet Of Things

Beoordeling
-
Verkocht
-
Pagina's
16
Geüpload op
04-01-2025
Geschreven in
2024/2025

Lecture notes of 16 pages for the course Internet Of Things at Anna University Chennai (unit 4 notes)

Instelling
Vak

Voorbeeld van de inhoud

1. Start an instance in EC2
EC2(Elastic Compute Cloud) it is a virtual server that provides resizable
computing capacity on cloud

FLOW:
1) Make connection
2) Make reservation
3) Check reservation status

import boto.ec2
from time import sleep


#ACESS_key,SECRET_KEY etc are user defined
#ACCESS_KEY,SECRET_KEY AND REGION are common for all the services
ACCESS_KEY='<Access key>'
SECRET_KEY="<Secret key>"
REGION='us-east-1'


#connect to EC2
#common to all codes
conn=boto.ec2.connect_to_region(REGION,aws_access_key_id=ACCESS_KEY,aws_s
ecret_access_key=SECRET_KEY)


#Basically connect to region function needs two argument, a region and a
#dictionary. the above function is similar to
#boto.ec2.connect_to_region(REGION, {aws_access_key_id:ACCESS_KEY,
aws_secret_access_key=SECRET_KEY} )


#AMI_ID is the image id of the image which we want to launch
#EC2_KEY_HANDLE is the key pair which we want to use to launch the
instance
#SECURITY_GROUP is the security group which we want to use to launch the
instance
#AMI_ID, INSTANCE_TYPE, EC2_KEY_HANDLE AND SECURITY GROUP VARIES FOR EACH
CODE
AMI_ID='<AMI_ID>'
INSTANCE_TYPE='t2.micro'
EC2_KEY_HANDLE='mykey'
SECURITY_GROUP='mygroup'

,#LAUNCHING INSTANCE
reservation=conn.run_instances(AMI_ID, key_name=EC2_KEY_HANDLE,
instance_type=INSTANCE_TYPE, security_groups=[SECURITY_GROUP])
instance=reservation.instances[0] #choosing 0th from list of instances


print ("Instance Launched")
#WAITING FOR INSTANCE TO BECOME ACTIVE


state=instance.update()
while state=='pending':
print ("Instance is pending")
sleep(5)
state=instance.update()


if(state=='running'):
print ("Instance is running")
print("Instance ID: ",instance.id)
print("Instance Public DNS: ",instance.public_dns_name)
print("launch time: ",instance.launch_time)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Terminating a EC2 instance

import boto.ec2
from time import sleep


ACCESS_KEY='<ACCESS_KEY>'
SECRET_KEY="<Seceret key>"
REGION='us-east-1'


AMI_ID='<AMI_ID>'
INSTANCE_TYPE='t2.micro'
EC2_KEY_HANDLE='mykey'
SECURITY_GROUP='mygroup'


#connect to EC2

, conn=boto.ec2.connect_to_region(REGION,aws_access_key_id=ACCESS_KEY,aws_s
ecret_access_key=SECRET_KEY)


#getting all reservations with all its instances
reservations=conn.get_all_instances()


#iterating through all the instances
instance_rs=reservations[0].instances
instance=instance_rs[0]
instanceid=instance.id


#stopping the instance
conn.stop_instances(instance_ids=[instanceid])


#waiting for the instance to stop
state=instance.update()
while state=='stopping':
print ("Instance is stopping")
sleep(5)
state=instance.update()
print ("Instance is stopped")



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. AutoScaling
Autoscaling is a AWS service which is used to launch or terminate EC2
instances based on user defined policies(Scaling up / Scaling down)
import boto.ec2.autoscale
from boto.ec2.autoscale import *
import boto.ec2.cloudwatch
from time import sleep


ACCESS_KEY ="<Access key>"
SECRET_KEY="<Secret key>"
REGION='us-east-1'


FLOW:
4) Connect to region with autoscale;

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
4 januari 2025
Aantal pagina's
16
Geschreven in
2024/2025
Type
College aantekeningen
Docent(en)
Dr janani
Bevat
Alle colleges

Onderwerpen

$8.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
gousigavs

Maak kennis met de verkoper

Seller avatar
gousigavs Sri Venkateswara College of Engineering
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
1 jaar
Aantal volgers
0
Documenten
5
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen