Launch EC2 From AWS Lambda - This was done using an AWS Academy Learner Lab Account

Subscribers:
1,220
Published on ● Video Link: https://www.youtube.com/watch?v=v3wj75-riCU



Duration: 13:48
68 views
2


Using an AWS Academy Learner Lab account... We used a single sign-on URL to log in, and created a basic lambda function that is triggered by a web URL. We then added the ability to create a server when hitting that URL. You will need to change a few things. We showed how to choose the AMI, Instance Type, and KeyName. We may have found a bug that may allow us to run ec2 after the lab shuts down, but I think my lab just did not shut down properly.

Here is my lambda code:

import time, json, boto3
region = 'us-west-2'
ec2 = boto3.resource('ec2')
client = boto3.client('ec2')

def lambda_handler(event, context):
# TODO implement
instances = ec2.create_instances(ImageId='ami-09d3b3274b6c5d4aa', MinCount=1, MaxCount=1,InstanceType='t2.micro', KeyName='Main')
print('created your instances: ' + str(instances))
myjunkinstance=str(instances)
print(myjunkinstance)
myinstance=myjunkinstance[18:37]
print(myinstance)

#I hate to sleep, but it may not get an ip address immediately
#time.sleep(.1)
#response = client.describe_instances(InstanceIds=[myinstance])

return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda! I have created the following ec2 instance for you... Enjoy ' + str(myinstance))

}




Other Videos By Information Technology


2022-12-20100 Sub Special... meet the competition
2022-12-20My AWS Certifications have expired... It is a sad day
2022-12-19CompTIA says I'm a professional - CompTIA Linux Network Professional – CLNP Stackable Certification
2022-12-16Has your social media been hacked - Watch this video to find out what to do - even the secret stuff
2022-12-16I received the CompTIA Secure Infrastructure Specialist – CSIS Stackable Certification
2022-12-15I got the CompTIA IT Operations Specialist – CIOS Stackable Certification
2022-12-14I passed the CompTIA Network+ Certification Exam
2022-12-13I got the CompTIA Systems Support Specialist – CSSS Stackable Certification
2022-12-12Children
2022-12-12I passed the Linux+ certification exam from CompTIA
2022-11-08Launch EC2 From AWS Lambda - This was done using an AWS Academy Learner Lab Account
2022-10-13Create Random Files in Learners Home Directories
2022-10-13Create 90 SFTP Only Users With a Single Command
2022-10-13Setting up a chrooted sftponly system for users in a specific group
2022-10-13Understanding Network Connections and installing Cups - Why do we print so much, arg! EC2 Metadata
2022-10-13Setup and Apache Web Server on AWS EC2
2022-10-13Systems Administrators Should Learn From Others Mistakes - Look at Standards
2022-10-13Playing with Split, Cat and Diff in linux using AWS
2022-09-23Finding files in linux and then doing something with that information (locate, find, updatedb, exec)
2022-09-22Linux Cut, Paste, Sort, Uniq, Tr, and Egrep - lets play
2022-09-22Cost of EC2 in AWS and touching on how to learn Regular Expressions