Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

When you request spot instance, Amazon require userdatа to be in base64 format. Example:

aws ec2 request-spot-instances \
--spot-price 0.01 \
--instance-count 2 \
--launch-specification \
    "{ \
        \"ImageId\":\"ami-a6926dce\", \
        \"InstanceType\":\"m3.medium\", \
        \"KeyName\":\"test-key\", \
        \"SecurityGroups\": [\"test-sg\"], \
        \"UserData\":\"`base64 userdata.sh`\" \
    }"

More info at: Request spot instances

Example is from: Small Tip: How to use AWS CLI to start Spot instances with UserData

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.