I can launch an ec2 instance without user data:
aws ec2 request-spot-instances –spot-price .01 –instance-count 1 –launch-specification '{ "ImageId": "ami-3275ee5b", "KeyName": "key", "InstanceType": "t1.micro"}'
But when I try it with userdata I get the following error:
aws ec2 request-spot-instances –spot-price .01 –instance-count 1 –launch-specification '{ "ImageId": "ami-3275ee5b", "KeyName": "key", "UserData": {"Fn::Base64" : { "Fn::Join" : ["", ["#!/bin/bash\n","touch /tmp/userdata_sucess\n"]]}}, "InstanceType": "t1.micro"}'
Invalid value ('OrderedDict([(u'Fn::Base64', OrderedDict([(u'Fn::Join', [u'', [u'#!/bin/bash\n', u'touch /tmp/userdata_sucess\n']])]))])') for param string:UserData of type string
I was following the example here
Best Answer
When you request spot instance, Amazon require userdatŠ° to be in base64 format. Example:
More info at: Request spot instances
Example is from: Small Tip: How to use AWS CLI to start Spot instances with UserData