【发布时间】:2021-10-21 05:41:14
【问题描述】:
我正在创建一个附有 SSM 的 EC2 实例。
def createInstances(self):
instances = self.ec2_client.create_instances(
ImageId="ami-09e67e426f25ce0d7", # Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
MinCount=1,
MaxCount=1,
InstanceType="m4.2xlarge",
KeyName="ec2-key-pair",
IamInstanceProfile={
'Arn': 'arn:aws:iam::aws:instance-profile/AmazonEC2RoleforSSM',
'Name': 'AmazonEC2RoleforSSM'
},
DryRun=True,
TagSpecifications=[
{
'ResourceType': 'instance',
'Tags': [
{
'Key': 'department',
'Value': 'dev'
},
]
},
],
)
print(instances["Instances"][0])
我收到如下错误:
botocore.exceptions.ClientError: An error occurred (InvalidParameterCombination) when calling the RunInstances operation: The parameter 'iamInstanceProfile.name' may not be used in combination with 'iamInstanceProfile.arn'
当我删除“iamInstanceProfile.name”时,我收到另一个错误:
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RunInstances operation: Value (arn:aws:iam::aws:instance-profile/AmazonEC2RoleforSSM) for parameter iamInstanceProfile.arn is invalid. Invalid IAM Instance Profile ARN
【问题讨论】:
标签: python-3.x amazon-web-services amazon-ec2 boto3 aws-ssm