我的cloudformation模板中有这样的东西
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#cloud-config\n",
"repo_releasever: ",
{
"Ref": "LinuxVersion"
},
"\n",
"\n",
"runcmd:\n",
" - [curl, -s, -S, -o, /tmp/user_data.txt, 'http://some.s3bucket.amazonaws.com/cfn/some_Script.txt']\n",
" - [bash, /tmp/user_data.txt]\n",
" - [mkdir, -p, /root/.aws/\n",
" - [echo, ' aws_access_key_id = ", { "Ref": "AWSAccessKey" }, " >> /root/.aws/credentials']\n",
" - [echo, ' aws_secret_access_key' = ", { "Ref": "AWSSecretAccessKey" }, " >> /root/.aws/credentials']\n"
]
]
}
}
}
},
CloudFormation配置实例后,如果执行此操作则无。
在/ var / lib / cloud / instance / scripts /.
中没有创建任何内容 时,我确实看到了剧本答案 0 :(得分:1)
我认为您的UserData的第一行必须是"#!/bin/bash\n",
才能使其成为可运行的脚本,因此您的代码的前几行将是:
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"#cloud-config\n",
"repo_releasever: ",