我不知道如何在Boto3中使用指定的IAM角色启动EC2实例。
以下是我目前成功创建实例的一些示例代码:
import boto3
ec2 = boto3.resource('ec2', region_name='us-west-2')
ec2.create_instances(ImageId='ami-1e299d7e', InstanceType='t2.micro',\
MinCount=1, MaxCount=1, SecurityGroupIds=['Mysecuritygroup'], KeyName='mykeyname')
create_instances
服务添加以下IAM权限以添加实例配置文件 -ec2.AssociateIamInstanceProfile
和iam.PassRole
。