我可以在没有用户数据的情况下启动 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"}'
无效值 ('OrderedDict([(u'Fn::Base64', OrderedDict([(u'Fn::Join', [u'', [u'#!/bin/bash\n', u'touch / tmp/userdata_sucess\n']])]))])') 用于参数字符串:字符串类型的用户数据
当您请求 Spot 实例时,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`\" \
}"
Run Code Online (Sandbox Code Playgroud)
更多信息请访问:请求 Spot 实例
示例来自:小技巧:如何使用 AWS CLI 通过 UserData 启动 Spot 实例
| 归档时间: |
|
| 查看次数: |
5031 次 |
| 最近记录: |