【发布时间】:2018-04-11 06:41:48
【问题描述】:
我已阅读此问题How do I use Boto3 to launch an EC2 instance with an IAM role? 并尝试在 python 脚本中启动具有 IAM 角色的实例。代码如下:
instance = ec2.create_instances(
ImageId='ami-1a7f6d7e',
KeyName='MyKeyPair',
MinCount=1,
MaxCount=1,
SecurityGroups=['launch-wizard-3'],
InstanceType='t2.micro',
IamInstanceProfile={
'Arn': 'arn:aws:iam::627714603946:instance-profile/SSMforCC'}
)
但是,我在运行脚本botocore.exceptions.ClientError: An error occurred (UnauthorizedOperation) when calling the RunInstances operation: You are not authorized to perform this operation.后得到了这个错误我发现这个问题how do I launch ec2-instance with iam-role?提供了Ruby的解决方案来解决这个问题。谁能告诉我是否有办法在 python Boto3 中解决这个问题?
【问题讨论】:
-
如果您只删除
IamInstanceProfile,相同的脚本是否有效? -
当我删除
IamInstanceProfile时它确实有效
标签: python amazon-web-services amazon-ec2 boto3