Is there a way of using a made key pair when creating a new instance using python 3. Can i just insert a new line into this code?
#!/usr/bin/env python3
import boto3
ec2 = boto3.resource('ec2')
instance = ec2.create_instances(
ImageId='ami-0713f98de93617bb4',
MinCount=1,
MaxCount=1,
InstanceType='t2.nano')
print (instance[0].id)
Specify a KeyName parameter like this:
instance = ec2.create_instances(
ImageId='ami-0713f98de93617bb4',
MinCount=1,
MaxCount=1,
InstanceType='t2.nano',
KeyName='myKeyName')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.