I am trying to create a new spot request using aws cli but it gives me an error if i pass a shell script as user-data to spot request
i tried this
aws ec2 request-spot-instances --spot-price "0.04" --instance-count 1 --launch-specification "{\"UserData\": \"/srv/user-data.sh\",\"InstanceType\": \"m1.small\"}"
and this gives me an error
Invalid BASE64 encoding of user data (400 response code)
and
how can i Tags my spot request with Name & Value
Exactly that, aws expects a base64 encoded string to be passed for the UserData value. Why the tools doesn't do this for you, I don't know.
So, instead of the string:
/srv/user-data.sh
Use a base64 encoded version of the string (using an online encoder, I got the following):
L3Nydi91c2VyLWRhdGEuc2g=
I'm guessing the final json it should look something like this:
'{"UserData": "L3Nydi91c2VyLWRhdGEuc2g=","InstanceType": "m1.small"}'
Creating tags is pretty straight forward. Here's a link to the 'aws' CLI command documentation: http://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html
You'll need to determine the resource AMI id:
aws ec2 create-tags --resources ami-78a54011 --tags Key=Name,Value=myname
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With