gpt4 book ai didi

cloud-init - cloudformation 似乎没有在 UserData 中运行(或创建)脚本

转载 作者:行者123 更新时间:2023-12-03 07:26:03 25 4
gpt4 key购买 nike

我的 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/中没有创建任何内容。

当我 curl http://169.254.169.254/latest/user-data 时,我确实看到了脚本

最佳答案

我认为你的 UserData 的第一行必须是 "#!/bin/bash\n", 才能使其成为可以运行的脚本,所以你的前几行代码为:

"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"#cloud-config\n",
"repo_releasever: ",

关于cloud-init - cloudformation 似乎没有在 UserData 中运行(或创建)脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31617641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com