Browse Source

speedup AWS image selection by referencing ami directly, listing all images as done in the libcloud examples, takes several minutes now

master
Sebastian Rieger 2 years ago
parent
commit
615f0ce0d4
  1. 6
      example-projects/demo3-microservice-in-aws-destroy.py
  2. 28
      example-projects/demo3-microservice-in-aws.py

6
example-projects/demo3-microservice-in-aws-destroy.py

@ -33,9 +33,9 @@ def main():
# access_id = getpass.win_getpass("Enter your access_id:")
# secret_key = getpass.win_getpass("Enter your secret_key:")
# session_token = getpass.win_getpass("Enter your session_token:")
access_id = "ASIAU..."
secret_key = "7lafW..."
session_token = "IQoJb3JpZ...EMb//..."
access_id = "ASIAX..."
secret_key = "eGwE12j..."
session_token = "FwoGZXIvYXdzEK///////////wEaDE..."
###########################################################################
#

28
example-projects/demo3-microservice-in-aws.py

@ -1,6 +1,6 @@
import getpass
# import os
from libcloud.compute.base import NodeImage
from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider
@ -44,9 +44,9 @@ def main():
# access_id = getpass.win_getpass("Enter your access_id:")
# secret_key = getpass.win_getpass("Enter your secret_key:")
# session_token = getpass.win_getpass("Enter your session_token:")
access_id = "ASIAU..."
secret_key = "7lafW..."
session_token = "IQoJb3JpZ...EMb//..."
access_id = "ASIAX..."
secret_key = "WLxxXK+..."
session_token = "FwoGZXIvYXdzEMb//////////wEaDE5rX.......0SleZ+L75I9iEri9LA4hovWul8HvexhCBK8.......................Ae/T+VkUbcQRtJEDwg+gYCABuk0JlSj5Wk7YA65r3BSNJXZFpkhbek6VBjvE/cEt5fKZEhENcdFxjAcAJLd6bOWi/oGXU5e3PX3mcXgm0oJpz6h3wqD1LvSDtw5GDwn0BHiF1Mu.......................cm/VukK5F"
###########################################################################
#
@ -66,9 +66,9 @@ def main():
#
###########################################################################
print("Fetching images (AMI) list from AWS region. This will take a lot of seconds (AWS has a very long list of "
"supported operating systems and versions)... please be patient...")
images = conn.list_images()
# print("Fetching images (AMI) list from AWS region. This will take a lot of seconds (AWS has a very long list of "
# "supported operating systems and versions)... please be patient...")
# images = conn.list_images()
# image = ''
# for img in images:
@ -79,8 +79,18 @@ def main():
# image = img
# fetch/select the image referenced with ubuntu_image_name above
image = [i for i in images if i.name == ubuntu_image_name][0]
print(image)
# image = [i for i in images if i.name == ubuntu_image_name][0]
# print(image)
# select image directly to save time, as retrieving the image list takes several minutes now,
# need to change ami id here if updated or for other regions, id is working for course in
# summer term 2022, in region: us-east-1 and pointing to ubuntu 18.04 used in the instance wizard,
# to update AMI id use the create instance wizard and copy amd64 image id for ubuntu 18.04 in the
# desired region
image = NodeImage(id="ami-0e472ba40eb589f49",
name="ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20211129",
driver="hvm")
flavors = conn.list_sizes()
flavor = [s for s in flavors if s.id == flavor_name][0]

Loading…
Cancel
Save