We have multiple subnet and VPC. How do i define specific subnet and VPC during request_spot_instances?
following is my code:
client = boto3.client('ec2')
response = client.request_spot_instances(
DryRun=False,
ClientToken=''.join(random.choices(string.ascii_lowercase + string.digits, k=10)),
InstanceCount=1,
Type='one-time',
LaunchSpecification={
'ImageId': 'ami-db710fa3',
'KeyName': 'my_key',
'InstanceType': 'm4.4xlarge',
'Placement': {
'AvailabilityZone': 'us-east-2a',
},
'BlockDeviceMappings': [
{
'Ebs': {
# 'SnapshotId': 'snap-f70deff0',
'VolumeSize': 100,
'DeleteOnTermination': True,
'VolumeType': 'gp2',
'Iops': 300,
'Encrypted': False
},
},
],
'EbsOptimized': True,
'Monitoring': {
'Enabled': True
},
'SecurityGroupIds': ['sg-1231231' ],
'NetworkInterfaces': [
{
'DeviceIndex': 123,
'SubnetId': 'Subnet-df123123'
},
],
}
)
However, above code is throwing errors,
botocore.exceptions.ClientError: An error occurred (InvalidParameterCombination) when calling the RequestSpotInstances operation: Network interfaces and an instance-level security groups may not be specified on the same request
any help is appreciated Thank you