【发布时间】:2020-12-31 07:41:40
【问题描述】:
我在调试遇到的错误时遇到问题。
botocore.exceptions.ClientError: An error occurred (InvalidParameterCombination) when calling the RunInstances operation: Network interfaces and an instance-level subnet ID may not be specified on the same request
这是代码。
# Make EC2s with AWS Ubuntu 20
instances = subnet.create_instances(ImageId='ami-0885b1f6bd170450c',
InstanceType='m1.small',
MaxCount=num,
MinCount=num,
Monitoring={'Enabled': True},
KeyName=key_name,
IamInstanceProfile={
'Arn': 'arn goes here',
},
NetworkInterfaces=[{
'DeviceIndex': 0,
'SubnetId': subnet.subnet_id,
'AssociatePublicIpAddress': True,
'Groups': [security_group.group_id]
}])
令我困惑的是我没有指定顶级子网 ID。即使我完全删除了子网 ID,我也会收到错误消息。
我的猜测是默认设置了某些东西,但如果是这种情况,我不知道如何停止。
【问题讨论】:
-
Boto3 有一个子网对象 - 看来他正在调用这个方法:boto3.amazonaws.com/v1/documentation/api/latest/reference/… 我的第一个想法是,通过使用子网.create_instances,子网被无意中指定了两次,但奇怪的是文档似乎暗示尽管创建调用是通过特定的子网对象执行的,但未指定它将使用默认的 VPC 和子网。也许尝试离开 DeviceIndex?
-
没用 :(
标签: amazon-web-services amazon-ec2