繁体   English   中英

如何/我可以使用 python 3 设置一个实例以使用已经为 AWS ec2 制作的实例

[英]How/Can I set up an instance to use an already made for AWS ec2 using python 3

使用 python 3 创建新实例时,是否可以使用已制作的密钥对 3. 我可以在此代码中插入新行吗?

#!/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)

像这样指定 KeyName 参数:

instance = ec2.create_instances(
    ImageId='ami-0713f98de93617bb4',
    MinCount=1,
    MaxCount=1,
    InstanceType='t2.nano',
    KeyName='myKeyName')

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.ServiceResource.create_instances

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM