Initial commit
Project-1, part-1 started ready on local? 2.6s for 1000 req
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.env
|
||||
*.pem
|
||||
node_modules/
|
||||
*.log
|
||||
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2024 Kaushik Narayan R and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
26
Project-1/Part-1/instance_info.py
Normal file
@ -0,0 +1,26 @@
|
||||
import boto3
|
||||
from pprint import pprint
|
||||
|
||||
# creds from ~/.aws/credentials
|
||||
session = boto3.Session(profile_name="dev")
|
||||
|
||||
dev_ec2_client = session.client("ec2", region_name="us-east-1")
|
||||
|
||||
# Get all instances' information
|
||||
all_instances = dev_ec2_client.describe_instances()
|
||||
with open("output.txt", "w") as out_f:
|
||||
pprint(all_instances, stream=out_f)
|
||||
|
||||
print("Capacity Reservations:", len(all_instances["Reservations"]))
|
||||
for idx, reservation in enumerate(all_instances["Reservations"]):
|
||||
print("Reservation", idx + 1, ":-")
|
||||
print("\tGroups:", len(reservation["Groups"])) # TODO: add grp info logging
|
||||
print("\tInstances:", len(reservation["Instances"]))
|
||||
for inst_idx, instance in enumerate(reservation["Instances"]):
|
||||
print("\tInstance", inst_idx + 1, ":-")
|
||||
print("\t\tInstance ID:", instance["InstanceId"])
|
||||
print("\t\tInstance state:", instance["State"]["Name"])
|
||||
print(f"\t\t{instance["InstanceType"]} in {instance["Placement"]["AvailabilityZone"]}")
|
||||
print(f"\t\t{instance["CpuOptions"]["CoreCount"]}vCPU, {instance["Hypervisor"]} hypervisor")
|
||||
print(f"\t\t{instance["PlatformDetails"]} on {instance["RootDeviceType"]} volume")
|
||||
print("\t\tPublic IP address:", instance["PublicIpAddress"] if "PublicIpAddress" in instance else "N/A")
|
||||
4
Project-1/Part-1/requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
boto3
|
||||
numpy
|
||||
pandas
|
||||
requests
|
||||
28
Project-1/Part-1/run_instances.py
Normal file
@ -0,0 +1,28 @@
|
||||
import boto3
|
||||
|
||||
# creds from ~/.aws/credentials
|
||||
session = boto3.Session(profile_name="dev")
|
||||
dev_ec2_client = session.client("ec2", region_name="us-east-1")
|
||||
|
||||
# Create capacity reservation of instances
|
||||
ami_id = "ami-0c7217cdde317cfec" # Ubuntu Server 22.04 LTS, SSD on EBS, 64-bit (x86)
|
||||
reservation = dev_ec2_client.run_instances(
|
||||
ImageId=ami_id,
|
||||
KeyName='cse546-dev',
|
||||
MinCount=1, # if available instances are less than min_count, abort with no allocation
|
||||
MaxCount=1, # try to allocate max_count instances. we only need one for now
|
||||
InstanceType="t2.micro",
|
||||
TagSpecifications=[
|
||||
{"ResourceType": "instance", "Tags": [{"Key": "Name", "Value": "WebTier"}]}
|
||||
],
|
||||
)
|
||||
|
||||
print("Instances allocated successfully:", "Yes" if reservation else "No")
|
||||
print("Groups:", len(reservation["Groups"])) # TODO: add grp info logging
|
||||
print("Instances:", len(reservation["Instances"]))
|
||||
for inst_idx, inst in enumerate(reservation["Instances"]):
|
||||
print("Instance", inst_idx + 1, ":-")
|
||||
print("\tInstance ID:", inst["InstanceId"])
|
||||
print("\tInstance state:", inst["State"]["Name"])
|
||||
print(f"\t{inst["InstanceType"]} in {inst["Placement"]["AvailabilityZone"]}")
|
||||
print(f"\t{inst["CpuOptions"]["CoreCount"]}vCPU, {inst["Hypervisor"]} hypervisor")
|
||||
4
Project-1/Part-1/web-tier-express/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Web tier with ExpressJS
|
||||
|
||||
- Run `npm i` to install all dependencies
|
||||
- Start: `npm run dev` or `prod`
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |