Note that there are some explanatory texts on larger screens.

plurals
  1. POaws ec2 request-spot-instances CLI issues
    text
    copied!<p>Trying to start a couple of spot instances within a simple script, and the syntax supplied in the AWS documentation and aws ec2 request-spot-instances help output is listed in either JAVA or JSON syntax. How does one enter the parameters under the JSON syntax from inside a shell script?</p> <p>aws --version</p> <p>aws-cli/1.2.6 Python/2.6.5 Linux/2.6.21.7-2.fc8xen</p> <p>aws ec2 request-spot-instances help -- at the start of "launch specification" it lists JSON syntax</p> <p>--launch-specification (structure) Specifies additional launch instance information.</p> <pre><code> JSON Syntax: { "ImageId": "string", "KeyName": "string", }, .... "EbsOptimized": true|false, "SecurityGroupIds": ["string", ...], "SecurityGroups": ["string", ...] } </code></pre> <p>I have tried every possible combination of the following, adding &amp; moving brackets, quotes, changing options, etc, all to no avail. What would be the correct formatting of the variable $launch below to have this work? Other command variations -- "ec2-request-spot-instances" are not working in my environment, nor does it work if I try to substitute --spot-price with -p.</p> <pre><code>#!/bin/bash launch="{"ImageId":"ami-a999999","InstanceType":"c1.medium"} "SecurityGroups":"launch-wizard-6"" echo $launch aws ec2 request-spot-instances --spot-price 0.01 --instance-count 1 --type c1.small --launch-specification $launch </code></pre> <p>This provides result: Unknown options: SecurityGroups:launch-wizard-6</p> <p>Substituting the security group number has the same result.</p> <p>aws ec2 describe-instances works perfectly, as does aws ec2 start-instance, so the environment and account information are properly setup, but I need to utilize spot pricing.</p> <p>In fact, nothing is working as listed in this user documentation: <a href="http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RequestSpotInstances.html" rel="nofollow">http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RequestSpotInstances.html</a></p> <p>Thank you,</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload