changed keyName to vockey, changed instanceType to t2.micro as t2.nano can run into out of memory situation when starting mariadb
This commit is contained in:
		@@ -7,8 +7,8 @@ from botocore.exceptions import ClientError
 | 
			
		||||
#
 | 
			
		||||
################################################################################################
 | 
			
		||||
 | 
			
		||||
print("!!!!!!!! You cannot use RDS in AWS Educate Account !!!!!!!!")
 | 
			
		||||
exit(-1)
 | 
			
		||||
# print("!!!!!!!! You cannot use RDS in AWS Educate Account !!!!!!!!")
 | 
			
		||||
# exit(-1)
 | 
			
		||||
 | 
			
		||||
# place your credentials in ~/.aws/credentials, as mentioned in AWS Educate Classroom,
 | 
			
		||||
# Account Details, AWC CLI -> Show (Copy and paste the following into ~/.aws/credentials)
 | 
			
		||||
@@ -21,6 +21,7 @@ availabilityZone = 'us-east-1a'
 | 
			
		||||
 | 
			
		||||
# AMI ID of Amazon Linux 2 image 64-bit x86 in us-east-1 (can be retrieved, e.g., at
 | 
			
		||||
# https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:)
 | 
			
		||||
# TODO update to recent version of Amazon Linux 2 AMI?
 | 
			
		||||
imageId = 'ami-0d5eff06f840b45e9'
 | 
			
		||||
# for eu-central-1, AMI ID of Amazon Linux 2 would be:
 | 
			
		||||
# imageId = 'ami-0cc293023f983ed53'
 | 
			
		||||
@@ -153,8 +154,9 @@ response = rdsClient.create_db_instance(DBInstanceIdentifier="tug-of-war-rds-db1
 | 
			
		||||
    MasterUsername='cloud_tug_of_war',
 | 
			
		||||
    MasterUserPassword='cloudpass',
 | 
			
		||||
    VpcSecurityGroupIds=[security_group_id],
 | 
			
		||||
    #DBInstanceClass='db.m3.2xlarge',
 | 
			
		||||
    DBInstanceClass='db.t3.micro',
 | 
			
		||||
    # DBInstanceClass='db.m3.2xlarge',
 | 
			
		||||
    # DBInstanceClass='db.t3.micro',
 | 
			
		||||
    DBInstanceClass='db.t2.small',
 | 
			
		||||
    Tags=[
 | 
			
		||||
        {'Key': 'Name', 'Value': 'tug-of-war-rds-db1'},
 | 
			
		||||
        {'Key': 'tug-of-war-rds', 'Value': 'db'}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,8 +10,8 @@ from botocore.exceptions import ClientError
 | 
			
		||||
#
 | 
			
		||||
################################################################################################
 | 
			
		||||
 | 
			
		||||
print("!!!!!!!! You cannot use Auto Scaling Group in AWS Educate Account !!!!!!!!")
 | 
			
		||||
exit(-1)
 | 
			
		||||
# print("!!!!!!!! You cannot use Auto Scaling Group in AWS Educate Account !!!!!!!!")
 | 
			
		||||
# exit(-1)
 | 
			
		||||
 | 
			
		||||
# place your credentials in ~/.aws/credentials, as mentioned in AWS Educate Classroom,
 | 
			
		||||
# Account Details, AWC CLI -> Show (Copy and paste the following into ~/.aws/credentials)
 | 
			
		||||
@@ -26,15 +26,20 @@ availabilityZone3 = 'us-east-1c'
 | 
			
		||||
 | 
			
		||||
# AMI ID of Amazon Linux 2 image 64-bit x86 in us-east-1 (can be retrieved, e.g., at
 | 
			
		||||
# https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:)
 | 
			
		||||
# TODO update to recent version of Amazon Linux 2 AMI?
 | 
			
		||||
imageId = 'ami-0d5eff06f840b45e9'
 | 
			
		||||
# for eu-central-1, AMI ID of Amazon Linux 2 would be:
 | 
			
		||||
# imageId = 'ami-0cc293023f983ed53'
 | 
			
		||||
 | 
			
		||||
# potentially change instanceType to t2.micro for "free tier" if using a regular account
 | 
			
		||||
# for production, t3.nano seams better
 | 
			
		||||
instanceType = 't2.nano'
 | 
			
		||||
# as of SoSe 2022 t2.nano seams to be a bit too low on memory, mariadb first start can fail
 | 
			
		||||
# due to innodb cache out of memory, therefore t2.micro or swap in t2.nano currently recommended
 | 
			
		||||
# instanceType = 't2.nano'
 | 
			
		||||
instanceType = 't2.micro'
 | 
			
		||||
 | 
			
		||||
keyName = 'srieger-pub'
 | 
			
		||||
# keyName = 'srieger-pub'
 | 
			
		||||
keyName = 'vockey'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
################################################################################################
 | 
			
		||||
@@ -270,6 +275,7 @@ print("------------------------------------")
 | 
			
		||||
 | 
			
		||||
response = asClient.create_launch_configuration(
 | 
			
		||||
    #IamInstanceProfile='my-iam-role',
 | 
			
		||||
    IamInstanceProfile='EMR_AutoScaling_DefaultRole ',
 | 
			
		||||
    ImageId=imageId,
 | 
			
		||||
    InstanceType=instanceType,
 | 
			
		||||
    LaunchConfigurationName='tug-of-war-asg-launchconfig',
 | 
			
		||||
 
 | 
			
		||||
@@ -26,9 +26,13 @@ imageId = 'ami-0d5eff06f840b45e9'
 | 
			
		||||
 | 
			
		||||
# potentially change instanceType to t2.micro for "free tier" if using a regular account
 | 
			
		||||
# for production, t3.nano seams better
 | 
			
		||||
instanceType = 't2.nano'
 | 
			
		||||
# as of SoSe 2022 t2.nano seams to be a bit too low on memory, mariadb first start can fail
 | 
			
		||||
# due to innodb cache out of memory, therefore t2.micro or swap in t2.nano currently recommended
 | 
			
		||||
# instanceType = 't2.nano'
 | 
			
		||||
instanceType = 't2.micro'
 | 
			
		||||
 | 
			
		||||
keyName = 'srieger-pub'
 | 
			
		||||
# keyName = 'srieger-pub'
 | 
			
		||||
keyName = 'vockey'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
################################################################################################
 | 
			
		||||
 
 | 
			
		||||
@@ -22,15 +22,20 @@ availabilityZone = 'us-east-1b'
 | 
			
		||||
 | 
			
		||||
# AMI ID of Amazon Linux 2 image 64-bit x86 in us-east-1 (can be retrieved, e.g., at
 | 
			
		||||
# https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:)
 | 
			
		||||
# TODO update to recent version of Amazon Linux 2 AMI?
 | 
			
		||||
imageId = 'ami-0d5eff06f840b45e9'
 | 
			
		||||
# for eu-central-1, AMI ID of Amazon Linux 2 would be:
 | 
			
		||||
# imageId = 'ami-0cc293023f983ed53'
 | 
			
		||||
 | 
			
		||||
# potentially change instanceType to t2.micro for "free tier" if using a regular account
 | 
			
		||||
# for production, t3.nano seams better
 | 
			
		||||
instanceType = 't2.nano'
 | 
			
		||||
# as of SoSe 2022 t2.nano seams to be a bit too low on memory, mariadb first start can fail
 | 
			
		||||
# due to innodb cache out of memory, therefore t2.micro or swap in t2.nano currently recommended
 | 
			
		||||
# instanceType = 't2.nano'
 | 
			
		||||
instanceType = 't2.micro'
 | 
			
		||||
 | 
			
		||||
keyName = 'srieger-pub'
 | 
			
		||||
# keyName = 'srieger-pub'
 | 
			
		||||
keyName = 'vockey'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
################################################################################################
 | 
			
		||||
@@ -125,7 +130,7 @@ for i in range(3, 4):
 | 
			
		||||
        time.sleep(1)
 | 
			
		||||
        timeout -= 1
 | 
			
		||||
    if instance.public_ip_address is not None:
 | 
			
		||||
        print("tug-of-war-in-the-clouds can be accessed at: " + instance.public_ip_address)
 | 
			
		||||
        print("tug-of-war-in-the-clouds can be accessed at: http://" + instance.public_ip_address)
 | 
			
		||||
    else:
 | 
			
		||||
        print("Could not get public IP using boto3, this is likely an AWS Educate problem. You can however lookup the "
 | 
			
		||||
              "public ip from the AWS management console.")
 | 
			
		||||
 
 | 
			
		||||
@@ -22,15 +22,20 @@ availabilityZone = 'us-east-1a'
 | 
			
		||||
 | 
			
		||||
# AMI ID of Amazon Linux 2 image 64-bit x86 in us-east-1 (can be retrieved, e.g., at
 | 
			
		||||
# https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:)
 | 
			
		||||
# TODO update to recent version of Amazon Linux 2 AMI?
 | 
			
		||||
imageId = 'ami-0d5eff06f840b45e9'
 | 
			
		||||
# for eu-central-1, AMI ID of Amazon Linux 2 would be:
 | 
			
		||||
# imageId = 'ami-0cc293023f983ed53'
 | 
			
		||||
 | 
			
		||||
# potentially change instanceType to t2.micro for "free tier" if using a regular account
 | 
			
		||||
# for production, t3.nano seams better
 | 
			
		||||
instanceType = 't2.nano'
 | 
			
		||||
# as of SoSe 2022 t2.nano seams to be a bit too low on memory, mariadb first start can fail
 | 
			
		||||
# due to innodb cache out of memory, therefore t2.micro or swap in t2.nano currently recommended
 | 
			
		||||
# instanceType = 't2.nano'
 | 
			
		||||
instanceType = 't2.micro'
 | 
			
		||||
 | 
			
		||||
keyName = 'srieger-pub'
 | 
			
		||||
# keyName = 'srieger-pub'
 | 
			
		||||
keyName = 'vockey'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
################################################################################################
 | 
			
		||||
@@ -164,6 +169,8 @@ instanceIdDB = response['Instances'][0]['InstanceId']
 | 
			
		||||
privateIpDB = response['Instances'][0]['PrivateIpAddress']
 | 
			
		||||
# privateIpDB = response['Instances'][0]['NetworkInterfaces'][0]['NetworkInterfaceId']
 | 
			
		||||
 | 
			
		||||
print("Using private IP to connect to the db: " + privateIpDB);
 | 
			
		||||
 | 
			
		||||
instance = ec2Resource.Instance(instanceIdDB)
 | 
			
		||||
instance.wait_until_running()
 | 
			
		||||
 | 
			
		||||
@@ -232,7 +239,9 @@ for i in range(1, 3):
 | 
			
		||||
        time.sleep(1)
 | 
			
		||||
        timeout -= 1
 | 
			
		||||
    if instance.public_ip_address is not None:
 | 
			
		||||
        print("tug-of-war-in-the-clouds can be accessed at: " + instance.public_ip_address)
 | 
			
		||||
        print("tug-of-war-in-the-clouds can be accessed at: http://" + instance.public_ip_address)
 | 
			
		||||
        print("Using AWS Academy Lab you should be able to login as shown in the lab README using:")
 | 
			
		||||
        print("ssh -i ~/.ssh/labsuser.pem ec2-user@" + instance.public_ip_address)
 | 
			
		||||
    else:
 | 
			
		||||
        print("Could not get public IP using boto3, this is likely an AWS Educate problem. You can however lookup the "
 | 
			
		||||
              "public ip from the AWS management console.")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user