I've been using the following specification to request p2.xlarge spot instances via the CLI.
You'll need to change the following parameters for your requests:
- KeyName (if different - make sure this key exists in the region)
- Placement.AvailabilityZone - Availability zone to start in
Make sure the subnet exists in the provided availability zone.
You can use the following command to request the spot instance
aws ec2 request-spot-instances --cli-input-json=file://request_spot.json --spot-price 0.20 --region us-east-1
To get the public IP of the instance you can use
aws ec2 describe-instances --region us-east-1 --output text | grep b43d1ec7
You can also modify the specification file to attach additional existing EBS volumes if required.