我可以启动一个没有用户数据的ec2实例:
aws ec2 request-spot-instances –spot-price .01 –instance-count 1 –launch-specification'{“ImageId”:“ami-3275ee5b”,“KeyName”:“key”,“InstanceType” t1.micro“}”
但是,当我用userdata尝试它时,我得到以下错误:
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“}”
- Nginx:403对某些文件扩展名禁止
- aws ec2和Django ALLOWED_HOSTS
- 检查不同服务器之间加载速度慢的原因
- 无法删除AWS快照 – 指的是不存在的实例ID
- EC2 t2.medium上的Ubuntu 14.04 HVM
无效值('OrderedDict([(u'Fn :: Base64',OrderedDict([(u'Fn :: Join',[u'',[u'#!/ bin / bash \ n',u'touch / tmp / userdata_sucess \ n']])]))])')for param string:UserDatatypes的string
我是在这里的例子
当您请求专色实例时,Amazon要求userdatа使用base64格式。 例:
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`\" \ }"
更多信息: 请求现场实例
示例来自: 小提示:如何使用AWS CLI以UserData启动Spot实例
对我来说,只有下面的命令有效,但不是Dimitrov提出的:
user="$(cat /scripts/userdata.sh | base64 -w 0)" aws ec2 request-spot-instances \"UserData\": \"$user\",\"InstanceType\": \"m1.small\"}"