运行用户数据脚本AWS EC2时出现问题

pkm*_*pkm 5 python amazon-ec2 amazon-web-services

是否可以通过AWSCLI(用户数据)运行python脚本。我尝试过,但没有运行,并且我的日志中有关注者

boot.log:2015-08-07 10:08:30,660 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: './step-1
cloud-init.log:2015-08-07 10:08:30,660 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: './step-1'
cloud-init-output.log:2015-08-07 10:08:30,660 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: './step-1'
Run Code Online (Sandbox Code Playgroud)

注意step-1是我尝试作为用户数据传递的脚本。我的脚本也存在于我正在运行命令的同一目录中,因此它应该选择

Axe*_*ehl 18

默认解释器似乎是Python。因此,如果您只想执行 shell 脚本,则需要以 hash-bang 开头,例如:

#!/bin/bash 
/yourpath/step-1
Run Code Online (Sandbox Code Playgroud)

请注意,为了调试此问题,请尝试: cat /var/log/cloud-init-output.log 并参见:https ://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html #用户数据shell脚本


xda*_*ays 1

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

aws 的文档说仅支持 shell 和 cloud-init 指令

  • 我的情况,我忘记了以“#!/bin/bash”开头 (12认同)