diff --git a/__pycache__/automation.cpython-38.pyc b/__pycache__/automation.cpython-38.pyc new file mode 100644 index 0000000..fa398e2 Binary files /dev/null and b/__pycache__/automation.cpython-38.pyc differ diff --git a/__pycache__/ec2.cpython-38.pyc b/__pycache__/ec2.cpython-38.pyc new file mode 100644 index 0000000..883e9b6 Binary files /dev/null and b/__pycache__/ec2.cpython-38.pyc differ diff --git a/__pycache__/menu.cpython-38.pyc b/__pycache__/menu.cpython-38.pyc new file mode 100644 index 0000000..158afcd Binary files /dev/null and b/__pycache__/menu.cpython-38.pyc differ diff --git a/ec2.py b/ec2.py new file mode 100644 index 0000000..51064b2 --- /dev/null +++ b/ec2.py @@ -0,0 +1,279 @@ +import os +from subprocess import PIPE, run, check_output,call + +profile = "" +keyfile = "" + +# wrapper to get ouput of system command +def out(command): + result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True) + return result.stdout + + +# function to launch AWS instances +def launchInstance(): + keyname, securityGroup, rc = keyAndSecurity() + + if rc != 0: + return + + print("\n1. Amazon Linux 2 AMI 64-bit (x86)\t2. RHEL 8 64-bit (x86)\t 3. Custom Image ID\t 4. Exit Instance Creation") + for i in range(5): + amiChoice = input("Enter choice (1-4) : ") + if amiChoice == '1': + imageID = "ami-0e306788ff2473ccb" + break + elif amiChoice == '2': + imageID = "ami-052c08d70def0ac62" + break + elif amiChoice == '3': + imageID = input("Enter Image ID : ") + break + elif amiChoice == '4': + print("Exiting...") + return + else: + if i == 4: + print("Entered wrong option 5 times. Exiting...") + return + print("Invalid choice!!! Choose from 1-4\n") + + + print("Create Instance with instanceID : {}, type : t2.micro, key-name : {}, security-group : {} ?".format(imageID, keyname, securityGroup)) + create = input("Enter Y to confirm : ") + if create == 'Y' or create == 'y': + errorInstance = call( + "aws ec2 run-instances --image-id {} --count 1 --instance-type t2.micro --key-name {} --security-groups {} --profile {}".format(imageID, keyname, securityGroup, profile)) + if errorInstance == 0: + instanceID = input("Enter the instance ID : ") + nametag = input("Enter name tag for instance (Eg. MyInstance): ") + call( + "aws ec2 create-tags --resources {} --tags Key=Name,Value={} --profile {}".format(instanceID, nametag, profile)) + print("Instance is created and running.\n") + return + + +# function to create key-pair and security group for instance +def keyAndSecurity(): + while True: + print("\nDefault values for each field taken if left blank => key-pair : MyKeyPair | security-group : my-sg | --description : My Security Group ") + keyPair = input("1. Enter name for new key-pair : ") + secGroup = input("2. Enter name for security group : ") + descSecurity = input( + "Enter description for security group {} : ".format(secGroup)) + if keyPair == '': + keyPair = "MyKeyPair" + if secGroup == '': + secGroup = "my-sg" + if descSecurity == '': + descSecurity = "My Security Group" + print("Entered fields : \nkey-pair : {}\nsecurity-group : {}\ndescription : {}\n".format( + keyPair, secGroup, descSecurity)) + confirm = input("Press Y to confirm : ") + if(confirm == 'Y' or confirm == 'y'): + # Creating Key-Pair + os.system(r"mkdir %USERPROFILE%\KeyPairs") + print(r"{}.pem created in folder C:\Users\%USERNAME%\KeyPairs ".format(keyPair)) + errorKeyPair = os.system( + r"aws ec2 create-key-pair --key-name {0} --profile {1} --output text > %USERPROFILE%\KeyPairs\{0}.pem".format(keyPair, profile)) + # Creating Security-Group + errorSecurityGroup = call( + 'aws ec2 create-security-group --group-name {} --description "{}" --profile {}'.format(secGroup, descSecurity, profile)) + if errorKeyPair != 0 or errorSecurityGroup != 0: + recreate = input( + "\nWould you like to delete created key-pair or security-group and try again ? (Press Y for Yes): ") + if recreate == 'Y' or recreate == 'y': + if errorKeyPair != 0 and errorSecurityGroup == 0: + rc = 11 + call( + "aws ec2 delete-security-group --group-name {} --profile {}".format(secGroup, profile)) + elif errorSecurityGroup != 0 and errorKeyPair == 0: + rc = 12 + call( + "aws ec2 delete-key-pair --key-name {} --profile {}".format(keyPair, profile)) + continue + else: + rc = 1 + break + else: + rc = 0 + print("rc : {}".format(rc)) + break + return (keyPair, secGroup, rc) + + +# function to add inbound rules to security group +def inboundRules(): + sgname = input("\nEnter security group name : ") + print("1. All Traffic (Default) 2. TCP 3. UDP 4. SSH 5. Custom Protocol : ") + for i in range(5): + plChoice = input("Choose between 1-5 : ") + if plChoice == '1' or plChoice == '': + protocol = 'all' + port = 'all' + break + elif plChoice == '2': + protocol = 'tcp' + port = '0-65535' + break + elif plChoice == '3': + protocol = 'udp' + port = '0-65535' + break + elif plChoice == '4': + protocol = 'tcp' + port = '22' + break + elif plChoice == '5': + protocol = input("Enter protocol number (Eg. 1 for ICMP, 6 for TCP etc.) : ") + port = input("Enter port range (leave blank for all by default): ") + if port == '': + port = 'all' + break + else: + if i == 4: + print("Entered wrong option 5 times. Exiting...") + return + print("Invalid choice!!! Choose from 1-5\n") + cidr = input("Enter custom cidr (leave blank for 0.0.0.0/0 by default) : ") + if cidr == '': + cidr = '0.0.0.0/0' + confirm = input("Confirm creation of inbound rule for Security Group : {} => for Protocol : {} \ + Port : {} and CIDR : {} ? (Press Y to confirm) : ".format(sgname, protocol, port, cidr)) + if confirm == 'y' or confirm == 'Y': + errorcheck = call("aws ec2 authorize-security-group-ingress --group-name {} --protocol {} \ + --port {} --cidr {} --profile {}".format(sgname, protocol, port, cidr, profile)) + print("rc : {}".format(errorcheck)) + return + + +def ec2menu(prof): + + global profile, keyfile + profile = prof + + print('\n') + while True: + print("\nEC2 MENU\ + \n--------") + print("\n1. Launch instance \t2. Show Key-Pairs \t3. Delete Key-Pair\ + \n4. Show Security-Groups \t5. Delete Security-Group \t6. Add Inbound Rules\ + \n7. Show Instances \t8. Start Instance \t9. Stop Instance\ + \n10.Terminate Instance \t11.Create EBS volume \t12.Attach EBS Volume\ + \n13.Show available storage \t14.Mount New Partition \t15.Show the filesystem\ + \n\nPress Q to exit") + + choice = input("> ") + if choice == '1': + launchInstance() + elif choice == '2': + os.system( + "aws ec2 describe-key-pairs --profile {}".format(profile)) + elif choice == '3': + keypair = input("\nEnter name of key-pair to delete : ") + error = os.system( + "aws ec2 delete-key-pair --key-name {} --profile {}".format(keypair, profile)) + if error == 0: + print("Key-Pair : {} deleted.".format(keypair)) + elif choice == '4': + os.system( + "aws ec2 describe-security-groups --profile {}".format(profile)) + elif choice == '5': + sg = input("\nEnter name of security-group to delete : ") + error = os.system( + "aws ec2 delete-security-group --group-name {} --profile {}".format(sg, profile)) + if error == 0: + print("Security-Group : {} deleted.".format(sg)) + elif choice == '6': + inboundRules() + elif choice == '7': + os.system("aws ec2 describe-instances --profile {}".format(profile)) + elif choice == '8': + instance_id = input("\nEnter instance-id : ") + error = call("aws ec2 start-instances --instance-ids {} \ + --profile {}".format(instance_id, profile)) + if error == 0: + print("Instance started successfully.") + print("rc : {}".format(error)) + elif choice == '9': + instance_id = input("\nEnter instance-id : ") + error = call("aws ec2 stop-instances --instance-ids {} \ + --profile {}".format(instance_id, profile)) + if error == 0: + print("Instance stopped successfully.") + print("rc : {}".format(error)) + elif choice == '10': + instance_id = input("\nEnter instance-id : ") + error = call("aws ec2 terminate-instances --instance-ids {} \ + --profile {}".format(instance_id, profile)) + if error == 0: + print("Instance termination processed. Instance will be deleted in some time.") + print("rc : {}".format(error)) + elif choice == '11': + size = input("Enter volume size : ") + az = input("Enter availability zone (Default : ap-south-1a): ") + if az == '': + az = 'ap-south-1a' + error = call("aws ec2 create-volume --availability-zone {} --size {} \ + --profile {}".format(az, size, profile)) + if error == 0: + print("EBS Volume created successfully") + print("rc : {}".format(error)) + elif choice == '12': + volume = input("Enter your volume-id : ") + instance = input("Enter instance-id : ") + error = call("aws ec2 attach-volume --volume-id {} --instance-id {} \ + --device /dev/sdh --profile {}".format(volume, instance, profile)) + if error == 0: + print("EBS Volume attached successfully") + print("rc : {}".format(error)) + elif choice == '13': + key = input("Enter key name with .pem extension: ") + address = out("echo %USERPROFILE%").rstrip("\n") + key = r"{}\KeyPairs\{}".format(address, key) + instance = input("Enter instance-id : ") + publicDns = out("aws ec2 describe-instances --instance-ids {}\ + --query Reservations[*].Instances[*].[PublicDnsName] --output text".format(instance)).rstrip("\n") + error = os.system('ssh -i {} ec2-user@{} sudo fdisk -l'.format(key, publicDns)) + print("rc : {}".format(error)) + elif choice == '14': + key = input("Enter key name with .pem extension: ") + address = out("echo %USERPROFILE%").rstrip("\n") + key = r"{}\KeyPairs\{}".format(address, key) + instance = input("\nEnter instance-id : ") + publicDns = out("aws ec2 describe-instances --instance-ids {}\ + --query Reservations[*].Instances[*].[PublicDnsName] --output text".format(instance)).rstrip("\n") + name = input("Enter name of volume you wish to create partition in : ") + error = os.system("ssh -i {} ec2-user@{} sudo fdisk {}".format(key, publicDns, name)) + error2, error3 = 1,1 + if error == 0: + print("Partition {} created.".format(name)) + error2 = os.system("ssh -i {} ec2-user@{} sudo mkfs.ext4 {}".format(key, publicDns, name)) + if error2 == 0: + print("Partition {} formatted.".format(name)) + mount = input("Enter name for new mount point : ") + error3 = os.system("ssh -i {} ec2-user@{} sudo mkdir {}".format(key, publicDns, mount)) + error4 = os.system("ssh -i {} ec2-user@{} sudo mount {} {}".format(key, publicDns, name, mount)) + if error3 == 0 and error4 == 0: + print("Partition {} mounted on directory {}.".format(name, mount)) + print("rc : {}".format(error+error2+error3+error4)) + + elif choice == '15': + key = input("Enter key name with .pem extension: ") + address = out("echo %USERPROFILE%").rstrip("\n") + key = r"{}\KeyPairs\{}".format(address, key) + instance = input("\nEnter instance-id : ") + publicDns = out("aws ec2 describe-instances --instance-ids {}\ + --query Reservations[*].Instances[*].[PublicDnsName] --output text".format(instance)).rstrip("\n") + error = os.system("ssh -i {} ec2-user@{} sudo df -h".format(key, publicDns)) + print("rc : {}".format(error)) + + elif choice == 'Q' or choice == 'q': + print("Exiting...\n") + break + else: + print("Invalid choice!!! Choose from 1-15 or Q to exit.\n") + return + + + diff --git a/menu.py b/menu.py index 731d90d..01b5acc 100644 --- a/menu.py +++ b/menu.py @@ -1,279 +1,187 @@ -# ARTH TASK - Python scripting for all Technologies learnt -# Try to keep the code as neat as possible for easy understanding of changes and control flow - -gaius-aws -import os -import subprocess - -loginAWS = False -profile = "" - - -# function to launch AWS instances -def launchInstance(): - keyname, securityGroup, rc = keyAndSecurity() - - if rc != 0: - return - - exitflag = 0 - print("\n1. Amazon Linux 2 AMI 64-bit (x86)\t2. RHEL 8 64-bit (x86)\t 3. Custom Image ID\t 4. Exit Instance Creation") - for i in range(5): - amiChoice = input("Enter choice (1-4) : ") - if amiChoice == '1': - imageID = "ami-0e306788ff2473ccb" - break - elif amiChoice == '2': - imageID = "ami-052c08d70def0ac62" - break - elif amiChoice == '3': - imageID = input("Enter Image ID : ") - break - elif amiChoice == '4': - print("Exiting...") - return - else: - if i == 4: - exitflag = 1 - break - print("Invalid choice!!! Choose from 1-4\n") - if exitflag == 1: - print("Entered wrong option 5 times. Exiting...") - return - - print("Create Instance with instanceID : {}, type : t2.micro, key-name : {}, security-group : {} ?".format(imageID, keyname, securityGroup)) - create = input("Enter Y to confirm : ") - if create == 'Y': - errorInstance = subprocess.call( - "aws ec2 run-instances --image-id {} --count 1 --instance-type t2.micro --key-name {} --security-groups {} --profile {}".format(imageID, keyname, securityGroup, profile)) - if errorInstance == 0: - instanceID = input("Enter the instance ID : ") - nametag = input("Enter name tag for instance (Eg. MyInstance): ") - subprocess.call( - "aws ec2 create-tags --resources {} --tags Key=Name,Value={} --profile {}".format(instanceID, nametag, profile)) - print("Instance is created and running.\n") - return - - -# function to create key-pair and security group for instance -def keyAndSecurity(): - while True: - print("\nDefault values for each field taken if left blank => key-pair : MyKeyPair | security-group : my-sg | --description : My Security Group ") - keyPair = input("1. Enter name for new key-pair : ") - secGroup = input("2. Enter name for security group : ") - descSecurity = input( - "Enter description for security group {} : ".format(secGroup)) - if keyPair == '': - keyPair = "MyKeyPair" - if secGroup == '': - secGroup = "my-sg" - if descSecurity == '': - descSecurity = "My Security Group" - print("Entered fields : \nkey-pair : {}\nsecurity-group : {}\ndescription : {}\n".format( - keyPair, secGroup, descSecurity)) - confirm = input("Press Y to confirm : ") - if(confirm == 'Y' or confirm == 'y'): - # Creating Key-Pair - os.system(r"mkdir C:\KeyPairs") - print(r"{}.pem created in folder C:\KeyPairs\ ".format(keyPair)) - errorKeyPair = os.system( - r"aws ec2 create-key-pair --key-name {0} --profile {1} --output text > C:\KeyPairs\{0}.pem".format(keyPair, profile)) - # Creating Security-Group - errorSecurityGroup = subprocess.call( - 'aws ec2 create-security-group --group-name {} --description "{}" --profile {}'.format(secGroup, descSecurity, profile)) - if errorKeyPair != 0 or errorSecurityGroup != 0: - recreate = input( - "\nWould you like to delete created key-pair or security-group and try again ? (Press Y for Yes): ") - if recreate == 'Y' or recreate == 'y': - if errorKeyPair != 0 and errorSecurityGroup == 0: - rc = 11 - subprocess.call( - "aws ec2 delete-security-group --group-name {} --profile {}".format(secGroup, profile)) - elif errorSecurityGroup != 0 and errorKeyPair == 0: - rc = 12 - subprocess.call( - "aws ec2 delete-key-pair --key-name {} --profile {}".format(keyPair, profile)) - continue - else: - rc = 1 - break - else: - rc = 0 - print("rc : {}".format(rc)) - break - return (keyPair, secGroup, rc) - - -# function to add inbound rules to security group -def inboundRules(): - sgname = input("\nEnter security group name : ") - print("1. All Traffic (Default) 2. TCP 3. UDP 4. SSH 5. Custom Protocol : ") - for i in range(5): - plChoice = input("Choose between 1-5 : ") - if plChoice == '1' or plChoice == '': - protocol = 'all' - port = 'all' - break - elif plChoice == '2': - protocol = 'tcp' - port = '0-65535' - break - elif plChoice == '3': - protocol = 'udp' - port = '0-65535' - break - elif plChoice == '4': - protocol = 'tcp' - port = '22' - break - elif plChoice == '5': - protocol = input("Enter protocol number (Eg. 1 for ICMP, 6 for TCP etc.) : ") - port = input("Enter port range (leave blank for all by default): ") - if port == '': - port = 'all' - break - else: - if i == 4: - print("Entered wrong option 5 times. Exiting...") - return - print("Invalid choice!!! Choose from 1-5\n") - cidr = input("Enter custom cidr (leave blank for 0.0.0.0/0 by default) : ") - if cidr == '': - cidr = '0.0.0.0/0' - confirm = input("Confirm creation of inbound rule for Security Group : {} => for Protocol : {} \ - Port : {} and CIDR : {} ? (Press Y to confirm) : ".format(sgname, protocol, port, cidr)) - if confirm == 'y' or confirm == 'Y': - errorcheck = subprocess.call("aws ec2 authorize-security-group-ingress --group-name {} --protocol {} \ - --port {} --cidr {} --profile {}".format(sgname, protocol, port, cidr, profile)) - print("rc : {}".format(errorcheck)) - - -# function to configure AWS user profile -def awsConfigure(): - global loginAWS - global profile - - print("\nAWS Configure\ - \n-------------") - - name = input("Enter name of profile : ") - print("Region name for Mumbai AZ : ap-south-1 | Leave default output format blank for JSON") - errorCheck = os.system("aws configure --profile {}".format(name)) - print("rc : {}".format(errorCheck)) - - if errorCheck == 0: - loginAWS = True - profile = name - return - - -def awsMenu(): - print('\n') - os.system('aws --version') - - while True: - if not loginAWS: - awsConfigure() - else: - print("\nAWS MENU\ - \n--------") - print("\n1. Launch instance \t2. Show Key-Pairs \t3. Delete Key-Pair\ - \n4. Show Security-Groups\t5. Delete Security-Group\t6. Add Inbound Rules\ - \n7. Show Instances \t8. Start Instance \t9. Stop Instance\ - \n10.AWS Configure \t11.List Profiles \t\ - \n\nPress Q to exit") - choice = input("> ") - if choice == '1': - launchInstance() - elif choice == '2': - os.system( - "aws ec2 describe-key-pairs --profile {}".format(profile)) - elif choice == '3': - keypair = input("\nEnter name of key-pair to delete : ") - os.system( - "aws ec2 delete-key-pair --key-name {} --profile {}".format(keypair, profile)) - print("Key-Pair : {} deleted.".format(keypair)) - elif choice == '4': - os.system( - "aws ec2 describe-security-groups --profile {}".format(profile)) - elif choice == '5': - sg = input("\nEnter name of security-group to delete : ") - os.system( - "aws ec2 delete-security-group --group-name {} --profile {}".format(sg, profile)) - print("Security-Group : {} deleted.".format(sg)) - elif choice == '6': - inboundRules() - elif choice == '7': - os.system("aws ec2 describe-instances --profile {}".format(profile)) - elif choice == '8': - instance_id = input("\nEnter instance-id : ") - error = subprocess.call("aws ec2 start-instances --instance-ids {} \ - --profile {}".format(instance_id, profile)) - if error == '0': - print("Instance started successfully.") - print("rc : {}".format(error)) - elif choice == '9': - instance_id = input("\nEnter instance-id : ") - error = subprocess.call("aws ec2 stop-instances --instance-ids {} \ - --profile {}".format(instance_id, profile)) - if error == '0': - print("Instance stopped successfully.") - print("rc : {}".format(error)) - elif choice == '10': - awsConfigure() - elif choice == '11': - os.system("aws configure list-profiles") - elif choice == 'Q' or choice == 'q': - print("Exiting...\n") - break - else: - print("Invalid choice!!! Choose from 1-11 or Q to exit.\n") - return - - -# function to launch AWS instances -def lcaws(): - return - - -# function to launch Hadoop cluster -def lchadoop(): - return - - -# function to launch Docker containers -def lcdocker(): - return - - -# function to simulate ML models -def simml(): - return - - -# add more functions if required below - - - -while True: - print("\n\t\t\t\t-------------------\ - \n\t\t\t\t| TECH STACK MENU |\ - \n\t\t\t\t-------------------\n") - - # Add menu options based on your requirement or idea. These are just temporary for now. - # Based on added menu options, create functions too with additional elif statements. - print("1. AWS CLI\t 2. Configure Hadoop\t3. Configure Docker\n4. Simulate ML Model\n") - print("Press Q to quit.\n") - choice = raw_input("Enter your choice : ") - - if choice == '1': - lcaws() - elif choice == '2': - lchadoop() - elif choice == '3': - lcdocker() - elif choice == '4': - simml() - elif choice == 'Q' or choice == 'q': - break - else: - print("Invalid choice!!! Choose from 1-4 or Press Q to exit.\n") +# ARTH TASK - Python scripting for all Technologies learnt +# Try to keep the code as neat as possible for easy understanding of changes and control flow + +import os +import ec2 +from subprocess import PIPE, run, check_output,call + +import ec2 + +loginAWS = False +profile = "" + +# wrapper to get ouput of system command +def out(command): + result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True) + return result.stdout + + +# function to configure AWS user profile +def awsConfigure(): + global loginAWS + global profile + + print("\nAWS Configure\ + \n-------------") + + name = input("Enter name of profile : ") + print("Region name for Mumbai AZ : ap-south-1 | Leave default output format blank for JSON") + errorCheck = os.system("aws configure --profile {}".format(name)) + print("rc : {}".format(errorCheck)) + + if errorCheck == 0: + loginAWS = True + profile = name + return + + + +def webserver(): + + key = input("\nEnter key name with .pem extension: ") + address = out("echo %USERPROFILE%").rstrip("\n") + key = r"{}\KeyPairs\{}".format(address, key) + instance = input("Enter instance-id : ") + publicDns = out("aws ec2 describe-instances --instance-ids {}\ + --query Reservations[*].Instances[*].[PublicDnsName] --output text".format(instance)).rstrip("\n") + + while True: + error1, error2, error3, error4 = 0,0,0,0 + print("\n 1. Install Apache WebServer\ + \n 2. Start WebServer\ + \n 3. Stop WebServer\ + \n 4. Check Status\ + \n\n Press Q to quit") + choice = input("> ") + if choice == '1': + error1 = os.system("ssh -i {} ec2-user@{} sudo yum install httpd".format(key, publicDns)) + elif choice == '2': + error2 = os.system("ssh -i {} ec2-user@{} sudo systemctl start httpd".format(key, publicDns)) + if error2 == 0: + print("WebServer Started...") + elif choice == '3': + error3 = os.system("ssh -i {} ec2-user@{} sudo systemctl stop httpd".format(key, publicDns)) + if error3 == 0: + print("WebServer Stopped...") + elif choice == '4': + error4 = os.system("ssh -i {} ec2-user@{} sudo systemctl status httpd".format(key, publicDns)) + elif choice == 'q' or choice == 'Q': + break + else: + print("Invalid choice!!! Choose from 1-4 or Press Q to exit.\n") + print("rc : {}:{}:{}:{}".format(error1,error2,error3,error4)) + return + + +def s3(): + while True: + error1, error2 = 0,0 + print("\n 1. Create S3 Bucket\ + \n 2. Upload to S3 Bucket\ + \n\n Press Q to quit") + choice = input("> ") + if choice == '1': + bucket = input("Enter bucket name : ") + error1 = os.system("aws s3api create-bucket --bucket {} --region ap-south-1 \ + --create-bucket-configuration LocationConstraint=ap-south-1 --no-verify-ssl".format(bucket)) + if error1 == 0: + print("Bucket '{}' created successfully.".format(bucket)) + elif choice == '2': + file = input("Enter absolute path of file you wish to upload : ") + bucket = input("Enter bucket name : ") + error2 = os.system("aws s3 cp {} s3://{}/ --acl public-read-write".format(file, bucket)) + if error2 == 0: + print("File '{}' added to Bucket '{}' successfully.".format(file, bucket)) + elif choice == 'q' or choice == 'Q': + break + else: + print("Invalid choice!!! Choose 1 or 2 or Press Q to exit.\n") + return + + +def cloudfront(): + bucket = input("\nEnter bucket name : ") + print("Setting up CloudFront ...") + error = os.system( + "aws cloudfront create-distribution --origin-domain-name {}.s3.amazon.com".format(bucket)) + if error == 0: + print("CloudFront distribution created successfully.") + return + +def awsMenu(): + print('\n') + error = os.system('aws --version') + print(error) + if error != 0: + print("No version of AWS CLI found. Would you like to install AWS CLIv2 ? (Press Y to confirm)") + install = input("> ") + if install == 'y' or install == 'Y': + call("msiexec /i https://awscli.amazonaws.com/AWSCLIV2.msi") + return + else: + return + while True: + if not loginAWS: + awsConfigure() + else: + print("\nAWS MENU\ + \n--------") + print("\n1. EC2 2. Run Webserver 3. S3 4. CloudFront\ + \n\nPress Q to exit\n") + choice = input("> ") + if choice == '1': + ec2.ec2menu(profile) + elif choice == '2': + webserver() + elif choice == '3': + s3() + elif choice == '4': + cloudfront() + elif choice == 'Q' or choice =='q': + return + else: + print("Invalid choice!!! Choose from 1-4 or Press Q to exit.\n") + return + + +# function to launch Hadoop cluster +def lchadoop(): + return + + +# function to launch Docker containers +def lcdocker(): + return + + +# function to simulate ML models +def simml(): + return + + +# add more functions if required below - + + +while True: + print("\n\t\t\t\t-------------------\ + \n\t\t\t\t| TECH STACK MENU |\ + \n\t\t\t\t-------------------\n") + + # Add menu options based on your requirement or idea. These are just temporary for now. + # Based on added menu options, create functions too with additional elif statements. + print("1. AWS CLI\t 2. Configure Hadoop\t3. Configure Docker\n4. Simulate ML Model\n") + print("Press Q to quit.\n") + choice = input("> ") + + if choice == '1': + awsMenu() + elif choice == '2': + lchadoop() + elif choice == '3': + lcdocker() + elif choice == '4': + simml() + elif choice == 'Q' or choice == 'q': + break + else: + print("Invalid choice!!! Choose from 1-4 or Press Q to exit.\n") \ No newline at end of file