AWS ec2 RequestSpotInstances - InvalidSubnetID.NotFound when passing comma-separated subnet-ids

Viewed 412

According to the API docs and the boto3 docs, SubnetId in the RequestSpotLaunchSpecification can be a comma-separated list of Subnet-ids:

The IDs of the subnets in which to launch the instance. To specify multiple subnets, separate them using commas; for example, "subnet-1234abcdeexample1, subnet-0987cdef6example2".

When I do this with boto3, I get the following error:

botocore.exceptions.ClientError: An error occurred (InvalidSubnetID.NotFound) when calling the RequestSpotInstances operation: The subnet ID 'subnet-one,subnet-two,subnet-three' does not exist

I've tried both comma-separated, and comma-and-space-separated (as shown in the docs)

The request I'm making looks something like this:

{
  "BlockDurationMinutes": 60,
  "InstanceCount": 5,
  "LaunchSpecification": {
    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Ebs": {
          "VolumeSize": 10,
          "VolumeType": "gp3"
        }
      }
    ],
    "IamInstanceProfile": {
      "Arn": "arn:aws:iam::accountid:instance-profile/aprofile"
    },
    "ImageId": "image",
    "InstanceType": "instancetype",
    "KeyName": "keyname",
    "SecurityGroupIds": [
      "sg-one",
      "sg-two"
    ],
    "SubnetId": "subnet-one,subnet-two,subnet-three",
    "UserData": "userdata"
  },
  "SpotPrice": "0.61"
}

The only other mentions of InvalidSubnetID.NotFound online were caused by people setting the region on their boto3 client incorrectly,

Are the docs incorrect, or do I need to do something else in order to pass multiple subnets with my spot-instance request, for instance specify multiple matching NetworkInterfaces on the LaunchSpecification?

Update:

I've spoken to AWS support and confirmed that the documentation was wrong here. The docs have been updated to show that only one subnetId can be passed.

0 Answers
Related